Skip to content
Typetypesv0.14.4

TypedConstructor

Extracts the constructor signature from a constructor type. typeof on an abstract class gives an abstract new (...) signature that TypeScript refuses to assign to a plain new (...), and this drops the modifier so both kinds of class reference resolve to the same newable shape.

type TypedConstructor<ConstructorType> = ConstructorType extends new (
    ...args: infer A
) => infer R
    ? new (...args: A) => R
    : ConstructorType extends abstract new (...args: infer A) => infer R
      ? new (...args: A) => R
      : never;

ConstructorType

The constructor type to extract the signature from

ConstructorType