TypeScript · Exercise 1 of 6Next
Intermediate
Challenge: MyPick and MyReadonly
Write the generic types MyPick<T, K> and MyReadonly<T> so the two Expect lines in the starter compile. MyPick<Todo, 'title'> must be { title: string }, and MyReadonly<Todo> must equal the built-in Readonly<Todo>.
Do not remove the Equal and Expect helpers at the top: the checks use them. Do not use the built-in Pick or Readonly. A key that is not in the type (MyPick<Todo, 'owner'>) must be an error.
What Check tests
- Your code has no type errors
- MyPick works with two keys
- MyPick rejects a key that is not in the type
- MyReadonly makes assignment an error
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.