Parameters<T>

Constructs a tuple type from the parameters of function type T.

Since TS 3.1 Spec ↗

Syntax

Parameters<Type>

Returns

tuple type — A tuple of the parameter types of the function type T.

Examples

function greet(name: string, age: number) {}

type Args = Parameters<typeof greet>;
// [name: string, age: number]
function call<F extends (...a: any[]) => any>(
  fn: F,
  ...args: Parameters<F>
) {
  return fn(...args);
}

Notes

Uses `infer` to capture the parameter list as a labeled tuple. Combine with spread element access to forward arguments to a wrapped function. Use `ConstructorParameters` for constructor signatures.

See also