Mapped Types with Objects
In this exercise we'll be using the mapped type again, but this time working with an object instead of a union type.
We’ll starting with an
Attributes interface and an empty type helper
Your challenge is to use a mapped type to transform the members of
Attributes into a set of getter functions.
These functions should have the same key as the property they're getting, and they should return the type of the property as seen in the test:
Hint: Reference earlier lessons if you get stuck!
[0:00] We're going to continue building on this map type. Instead of looking at a union now, we're going to look at an object.
[0:07] This object here, we've got this interface Attributes here. What we really want to do is transform this Attributes into a set of getters, which are functions which will return the value here. The age function should return number. The lastName should return string. The firstName should return string.
[0:26] You'll need to use a map type for this and also maybe something that we've seen a little bit earlier, too.
[0:33] This is a really interesting problem. Good luck.