TypeScript Utility Types
ReturnType<T> — extract a callable result type
ReturnType extracts the return type of a callable declaration. It returns a static type, not the result of executing the function. With overloaded signatures it uses the last signature; an unconstrained generic return can become unknown. For an async function the return type includes the Promise wrapper; combine with Awaited when the fulfillment type is needed. Example output: "5 true". Verified with strict TypeScript 5.8.3, ES2022 and Node.js 22.16.0. This utility affects static typing; no runtime validation or transformation is supplied by the type itself.
Formal Syntax & Structure
typescript syntaxtypescript
ReturnType<T>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| T | T extends (...args: any) => any | Callable type whose result is extracted. |
Working Example
Example Snippettypescript
function createEntry(id: number) { return { id, ready: true }; }const result: ReturnType<typeof createEntry> = { id: 5, ready: true };console.log(result.id, result.ready);