TypeScript · Exercise 1 of 5Next
Intermediate
A Patch Type from Utilities
A server accepts a patch for a user: the id is always required, and every other field is optional. The type UserPatch doesn't exist yet, so the Types panel shows an error.
Write type UserPatch using only built-in utility types (Pick, Omit, Partial). The function applyPatch and the variable u are already written. The checks call applyPatch with good and bad patches.
What Check tests
- Your code has no type errors
- The console prints the patched user
- A patch with only
idandemailis accepted - A patch without
idis rejected - A patch with an unknown field is rejected
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.