function-types

ConstructorParameters<T>

Extracts the parameter tuple of a class constructor T. Mirrors Parameters but operates on `new (...)` signatures instead of call signatures.

type ConstructorParameters<T extends abstract new (...args: any) => any> = T extends abstract new (...args: infer P) => any ? P : never

Usage patterns

Pattern Purpose
ConstructorParameters<typeof Cls> Reuse a class's constructor arguments
abstract new (...args) The signature form it destructures
InstanceType<typeof Cls> Companion for extracting the instance type
...args: ConstructorParameters<T> Spread into a factory or wrapper

Examples

class Point { constructor(public x: number, public y: number) {} }
type PArgs = ConstructorParameters<typeof Point>;

Result: [x: number, y: number]

function factory<T extends new (...a: any) => any>(Cls: T, ...args: ConstructorParameters<T>) {
  return new Cls(...args);
}

Type-safe generic factory function

type EArgs = ConstructorParameters<ErrorConstructor>;

With modern lib (ES2022+), Error's second overload adds `options`, so `EArgs = [message?: string, options?: ErrorOptions]`. Last overload wins.

type Bad = ConstructorParameters<() => void>; // Error

T must have a construct signature — plain functions error out

Gotcha

Applies to `typeof ClassName` (the constructor), not the instance type. Abstract classes are supported since TS 4.2 thanks to the `abstract new` signature.

Related utility types

← All TS utility types · TypeScript vs JavaScript · any vs unknown vs never