- Error
- Reported by the type checker
TS2390
Constructor implementation is missing.
A class declares constructor overloads but no constructor with a body. Add the implementation after the overload signatures.
What it means
Constructor overload signatures only describe how the class can be constructed. A class that isn't declared or abstract-only still needs one constructor with a body that handles every overload.
Example
export class Point {
constructor(x: number, y: number);
constructor(xy: [number, number]);
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(3,3): error TS2390: Constructor implementation is missing.
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 a constructor with a body after the overloads, with parameters that accept every overload.
- If the class only describes an existing value, use a
declare classin a.d.tsfile.