Advanced
Write PickByValue
Write PickByValue<T, V>: a type that keeps only the properties of T whose value type fits V. Use a mapped type with an as clause that remaps non-matching keys to never.
The starter returns T unchanged, so the examples below don't type-check yet. The checks use Product and a few assignments of their own.
What Check tests
- Your code has no type errors
- The console prints the numbers
- The text fields are
titleandsku - A non-number property is rejected from the numbers
- A missing text property 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.