function-types
Parameters<T>
Extracts the parameters of a function type T as a tuple. Enables reusing a function's argument list for wrappers, currying, or higher-order utilities.
type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never Usage patterns
| Pattern | Purpose |
|---|---|
| Parameters<typeof fn> | Reuse a function's arg list from its value |
| Parameters<T>[0] | Get a single parameter by index |
| ...args: Parameters<T> | Spread into a wrapper function signature |
| ConstructorParameters<T> | Class-constructor equivalent |
Examples
function add(a: number, b: number) { return a + b; }
type A = Parameters<typeof add>; Result: [a: number, b: number]
function wrap<T extends (...a: any) => any>(fn: T) {
return (...args: Parameters<T>) => fn(...args);
} Generic wrapper that preserves the original signature
type Second = Parameters<(x: string, y: boolean) => void>[1]; Result: boolean
type P = Parameters<() => void>; Result: [] — empty tuple for zero-arg functions
Gotcha
Returns a tuple with parameter names as labels — those labels are cosmetic and can be dropped by later transforms. As with ReturnType, only the last overload signature is captured.
Related utility types
ReturnType<T>
Infers the return type of a function type T using `infer R`. Widely used to derive types from existing functions without redeclaring them.
ConstructorParameters<T>
Extracts the parameter tuple of a class constructor T. Mirrors Parameters but operates on `new (...)` signatures instead of call signatures.
ThisParameterType<T>
Extracts the explicit `this` parameter type from a function T, or `unknown` if none is declared. Useful for reflecting on method-style callbacks that require a specific caller.
infer R
A keyword usable only inside the extends clause of a conditional type that introduces a fresh type variable inferred from the matched shape. It is the primitive that powers ReturnType, Parameters, InstanceType, Awaited, and countless custom utilities.
OmitThisParameter<T>
Returns a function type identical to T but without its explicit `this` parameter. Commonly paired with `Function.prototype.bind` to model the bound function's signature.
← All TS utility types · TypeScript vs JavaScript · any vs unknown vs never