TypeScript · Generics and utility types
ReturnType<T>
Extracts the return type of a function type. Handy when you cannot import the type directly.
Syntax
ReturnType<typeof fn>Example
Example
function makeUser() {
return { id: "u1", name: "Ada" };
}
type User = ReturnType<typeof makeUser>;More in this group
Learn this in the course
Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.