Map an Object to a Union of Tuples
We start with a
The goal is to create a union of tuples containing the key/value pairs:
0:00 In this exercise, what we're trying to get to is we have Values here and we're trying to end up with values as a union of tuples. We're trying to grab email string, firstName string, or lastName string so this ends up as a union type.
0:16 What I've done is I've got you half of the way there. What we're doing is we're creating an object out of this, and we're saying K in keyof Values is...The syntax is horrible because we've got square brackets on one side, square brackets on the other, but this one creates a tuple here.
0:34 We're grabbing the key as the first one and then Values K as the second. What we get is we get email is "email", string, firstName, "firstName", string, lastName, "lastName", string.
0:44 Your challenge is to work out how we can take this and turn it into a union here.