On this page
Parameters
Prev: `ReturnType` | Up: function_and_promise | Next: `Awaited`
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
Parameters<Fn>
Extracts the parameter list of a function type Fn as a tuple.
Notes & Pitfalls
- Extracts a function's parameter list as a tuple: Great for wrapper functions when you don't own the underlying function's types.
Example
function createUser(name: string, admin: boolean) {
return { name, admin };
}
type CreateArgs = Parameters<typeof createUser>; // [name: string, admin: boolean]
const call = (...args: CreateArgs) => createUser(...args);
Linked from
Related notes
- tuts/typescript/utility_types/function_and_promise/Awaited Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/function_and_promise/ReturnType 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