Type Transformations Workshop (6 exercises)

Create an Object Whose Keys Are Derived From a Union

Now we'll start with a type called TemplateLiteralKey:

When we hover over it, we can see that it's creating a union out of two unions that are mashed together in a template literal:


Your challenge is to create an object out of those keys and assign it to ObjectOfKeys.

You don't need to change anything in TemplateLiteralKey– just add something to ObjectOfKeys.

The test shows what the result should look like:


[0:00] In this problem, we have a TemplateLiteralKey here. If we hover over this, we can see that it's basically creating userId, userName, postId, postName, commentID, commentName out of these two unions that it's mashing together.
[0:14] Our job now is to create an object of those keys where you basically have all of these automatically generated for you.

[0:23] That's your job, is to take this TemplateLiteralKey that's being represented here. You don't have to change anything here. All you have to do is assign something to this unknown and turn it into an object.