Dev Helpers

TypeScript / Interfaces and classes

Construct an instance from a typed constructor

Dev Helpers · March 13, 2026

A constructor signature describes something the helper can instantiate. The returned instance type can be inferred from the constructor argument.

Worked example

interface Named {
  name: string;
}
console.log(
  (<T,>(Ctor: new () => T) => new Ctor())(
    class {
      ready = true;
    },
  ),
);

Result

{ ready: true }

Implementation notes

An abstract constructor and an instantiable constructor are different contracts. A helper that calls new needs the latter.

Try it yourself

Pass a constructor with a required parameter and inspect the mismatch.

Open the TypeScript example →

Editorial date March 13, 2026 · Published December 6, 2026

Related articles

Reject fractional cent amounts

A numeric type cannot by itself guarantee whole cents. Validate integrality where money enters the typed part of the application.

Infer route names from a registry

A route registry can drive both lookup and allowed route names. Type the keys from the registry so a removed route cannot survive in a separate union.