TypeScript · Junior · Question 45 of 75

How do you get the return type of the createStore function?

Explanation

ReturnType takes a function type, so typeof is needed. Similarly, Parameters<typeof fn> gives a tuple of parameters. This way types are derived from the implementation instead of being duplicated.

Further reading

Problem with a question

TypeScript · Junior · question 45

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz