diff --git a/src/020-objects/065.2-no-autocomplete-on-omit.explainer.ts b/src/020-objects/065.2-no-autocomplete-on-omit.explainer.ts new file mode 100644 index 0000000..4c0ccd0 --- /dev/null +++ b/src/020-objects/065.2-no-autocomplete-on-omit.explainer.ts @@ -0,0 +1,15 @@ +type User = { + id: number; + name: string; + email: string; +}; + +// You can omit properties which don't exist! +type UserWithoutPhoneNumber = Omit; + +// But you CAN'T pick properties which don't exist +type UserWithOnlyPhoneNumber = Pick< + User, + // @ts-expect-error + "phoneNumber" +>; diff --git a/src/020-objects/065.5-omit-and-pick-cant-discribute.explainer.ts b/src/020-objects/065.5-omit-and-pick-cant-discribute.explainer.ts new file mode 100644 index 0000000..a25b577 --- /dev/null +++ b/src/020-objects/065.5-omit-and-pick-cant-discribute.explainer.ts @@ -0,0 +1,7 @@ +type DistributiveOmit = T extends any + ? Omit + : never; + +type DistributivePick = T extends any + ? Pick + : never;