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 AttributeGetters
:
interface Attributes { firstName: string lastName: string age: number}type
Transcript
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.