On this page
Awaited
Prev: `Parameters` | Up: function_and_promise | Next: `NoInfer`
Rel: function_and_promise, Conditional & Mapped Types
Ref: TypeScript Docs — Utility Types
Tags: #public #web #typescript #utility-types #function_and_promise #tier/core
Syntax & Overview
Awaited<T>
Recursively unwraps Promise / thenable types, mirroring runtime await.
Notes & Pitfalls
- Recursively unwraps nested
Promise/ thenable types: Mirrors the exact runtime unwrapping behavior ofawait.
Example
async function fetchUser() {
return { id: 1, name: "Ada" };
}
type User = Awaited<ReturnType<typeof fetchUser>>; // { id: number; name: string }
Linked from
Related notes
- tuts/typescript/utility_types/function_and_promise/NoInfer Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/function_and_promise/Parameters Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/function_and_promise Linked here; links to this page; shared tags: #typescript, #web
- tuts/typescript/type_system/conditional_and_mapped_types Linked here; shared tags: #typescript, #web
- tuts/typescript/builtins/any shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/as_const shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/enum shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/infer shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #tier, #typescript, #web