Awaited<T>
The utility type that unwraps a promise type to the value it resolves to, repeating through nested promises and thenables.
In more detail
Awaited<Promise<Promise<number>>> is number. Combined with ReturnType it extracts the resolved result of an async function or SDK call. It was added in TypeScript 4.5.
Related terms
- Promise — A JavaScript object that stands for a result that is not ready yet and will later either succeed with a value or fail with an error.
- ReturnType<T> — The utility type that gives the return type of a function type T.
- async and await — Language keywords for writing code that waits for slow work, such as a network call, without blocking a thread.
Taught in
- Core Utilities: Partial, Required, Readonly, Pick And Omit — Production TypeScript
- Union Utilities: Exclude, Extract, NonNullable And Awaited — Production TypeScript
- Mapped Types, Key Remapping With as And Template Literals — Production TypeScript