TypeScript · Junior · Question 45 of 75
How do you get the return type of the createStore function?
- ✓Correct answer:
ReturnType<typeof createStore> - 2
typeof createStore()with a function call - 3
ResultOf<createStore>from the standard library
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.