• Error
  • Reported by the type checker

TS7013

Construct signature, which lacks return-type annotation, implicitly has an 'any' return type.

A construct signature (`new (...)`) in a type has no return type, so it would return `any`. Add one.

What it means

Under noImplicitAny, a new (...) signature in an interface or type literal must say what it constructs. Without an annotation the constructed value is any.

Example

index.ts
export interface Factory {
  new (name: string);
}
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(2,3): error TS7013: Construct signature, which lacks return-type annotation, implicitly has an 'any' return type.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Add the instance type: new (name: string): User;.