TypeScript 7 reference · Utility Types

TypeScript Awaited<Type> Utility Type

Unwrap the value type of a Promise (recursively), like what await gives you. Awaited<Promise<number>> is number.

TypeScript 7 Since 4.5

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Awaited<Type>

Parameters

ParameterDescription
Type Usually a Promise<…> type.

Return value

The resolved value type.

Examples

Unwrap promisesTry it yourself
type A = Awaited<Promise<string>>;            // string
type B = Awaited<Promise<Promise<number>>>;   // number
const a: A = "ready";
const b: B = 42;
console.log(a, b);

Output

ready 42
The value an async function resolves toTry it yourself
async function loadUser() {
  return { id: 1, name: "Ana" };
}
type User = Awaited<ReturnType<typeof loadUser>>;
const u: User = await loadUser();
console.log(u.name);

Output

Ana

Version history

VersionChange
TypeScript 4.5Added

Was this page helpful?