Inference Basics 6 exercises
Problem

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:


const makeQuery = (
url: string,
opts?: {
method?: string;
headers?: {
[key: string]: string;
};

Loading exercise

Transcript

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.