Reference / TypeScript
ReturnType<Type>
Constructs a type consisting of the return type of function Type.
Syntax
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;Parameters
| Name | Type | Description |
|---|---|---|
| Type | Function | Target function type. |
Examples
Inferring factory output
function makeStore() { return { state: { count: 0 }, increment() {} }; }
type AppStore = ReturnType<typeof makeStore>;Requires typeof operator when referencing a value identifier.