Skip to content

CodeNot attempted

Type challenge: MyPick

Difficulty: easy

Implement MyPick<T, K> like the built-in Pick, without using it. Keys that aren't on T must be a compile error. Check types is the test.

Show reference solution
// A mapped type over only the chosen keys; the constraint rejects keys T doesn't have.
export type MyPick<T, K extends keyof T> = { [P in K]: T[P] };
Loading editor…