Type Transformations Workshop (9 exercises)

Extract Object Properties into Individual Types

Here, we've got an object called fakeDataDefaults that acts as mock GraphQL types for testing:

When hovering over fakeDataDefaults we can see the types of each field:


Your challenge is to turn fakeDataDefaults into a type, then extract each of the object into its individual pieces:

Consult the TypeScript Docs to find a utility type that looks useful for this scenario.


[0:00] Here, we've got an object called fakeDataDefaults. This is like imagine you wanted to put some fake data into a system for test. Then, you would have your GraphQL types here, so string, int, float, Boolean, ID.
[0:12] Except, what we want to do is extract the type of these into their own types. These fakeDataDefaults, we can see the string is the result of string. Int is the result of a number. Float, number. Boolean, Boolean. ID, string.

[0:26] We want to grab these and put them in here. That's your job, is to work out how we can both turn this into a type and extract the value of the object into each specific piece.