Conditionally Extract Properties from Object
We have an object that contains several keys that contain
Your challenge is to write the
OnlyIdKeys type helper so that it contains only the keys from the
Example interface that contain
Use the mapped type techniques from the previous lessons.
Hint: You might want to create an intermediate helper type as part of your solution. Refer back to previous lessons in the Conditional Types section may be helpful as well.
[0:00] [0: 00] In this exercise, we have an example object here with a bunch of keys in. Several of them have keys which contain IDs. We want to create a new object out of that using this type helper OnlyIdKeys to extract only the keys that contain an ID.
[0:19] [0: 20] We've got to do some funky steps here. We have to basically take the object. We need to think about remapping over the object and possibly using new keys from it, possibly using some syntax that we've seen before. You may notice that you might need a conditional type in here somewhere too.
[0:41] [0: 41] There are probably several solutions to this, but I've picked one that shows an interesting use case for key remapping, especially using never. Those are your clues. Good luck.