Type Transformations Workshop (4 exercises)

Extract Function Parameters Into A Type

Similar to the last exercise, we will be using one of TypeScript’s utility types to get types from a function.

This time we want to extract parameters from this makeQuery function:

Note that the tests show that MakeQueryParameters should return a tuple where the first value is url: string and the second is an optional opts object:

In order to get the types of the function parameters, you’ll need typeof as well as another utility type.


Instructor: [0:00] Similar to last exercise, your job here is to take this function, make query, and then get the parameters from the function. You're probably going to need typeof again, and you're probably going to need a different utility type.
[0:13] You notice that the thing it returns is actually a tuple here where the first member of the tuple is a URL string, and the second member is these opts here. That's your challenge.