Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
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

NameTypeDescription
TypeFunctionTarget 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.