diff --git a/src/type-challenges/0004-pick/main.ts b/src/type-challenges/0004-pick/main.ts new file mode 100644 index 0000000..1706abf --- /dev/null +++ b/src/type-challenges/0004-pick/main.ts @@ -0,0 +1,47 @@ +/** + * @copyright NHCarrigan + * @license Naomi's Public License + * @author Naomi Carrigan + */ + +import type { Equal, Expect } from "@type-challenges/utils"; + +/** + * Original code:. + * + * ```ts + * type MyPick = any + * ``` + */ + +type MyPick = { + [P in K]: T[P]; +}; + +/** + * Test cases. + */ + +// @ts-expect-error -- Unused variable. +// eslint-disable-next-line @typescript-eslint/no-unused-vars -- This is necessary for tests. +type Cases = [ + Expect>>, + Expect>>, + // @ts-expect-error -- Invalid key. + MyPick, +]; + +interface Todo { + title: string; + description: string; + completed: boolean; +} + +interface Expected1 { + title: string; +} + +interface Expected2 { + title: string; + completed: boolean; +}