conditional

Awaited<T>

Models the type produced by awaiting T, recursively unwrapping nested Promises (and other thenables). Introduced in TS 4.5 and used internally by the `await` expression's type.

type Awaited<T> = T extends null | undefined ? T : T extends object & { then(onfulfilled: infer F, ...args: any): any } ? F extends (value: infer V, ...args: any) => any ? Awaited<V> : never : T

Usage patterns

Pattern Purpose
Awaited<Promise<T>> Get the resolved value of a Promise
Awaited<ReturnType<AsyncFn>> Get the resolved return type of async functions
Awaited<Promise<Promise<T>>> Recursively unwraps to T
Awaited<T | Promise<U>> Distributes over unions, unwrapping only the promise members

Examples

type A = Awaited<Promise<string>>;

Result: string

type B = Awaited<Promise<Promise<number>>>;

Result: number — recursively unwraps nested promises

async function fetchUser() { return { id: 1 }; }
type User = Awaited<ReturnType<typeof fetchUser>>;

Idiomatic way to type the awaited return of an async function

type C = Awaited<number>;

Result: number — passthrough for non-thenables

Gotcha

Unlike a simple `T extends Promise ? U : T`, Awaited recurses through nested thenables — matching the runtime behavior of `await`. Custom thenables must have a `then` method to be unwrapped.

Related utility types

← All TS utility types · TypeScript vs JavaScript · any vs unknown vs never