- Error
- Reported by the type checker
TS2351
This expression is not constructable.
`new` is used on a value that has no construct signature. Make sure it's a class or constructor.
What it means
new X() needs X to have a construct signature, such as a class. Using new on an object, an instance or another value without one is reported here, with a second line naming the type. (With noImplicitAny, new on a plain function expression is reported as TS7009 instead.)
Example
const settings = { theme: "dark" };
export const s = new settings();
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(3,22): error TS2351: This expression is not constructable.
Type '{ theme: string; }' has no construct signatures.
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
- Call it without
newif it's a plain function. - Use a class if you need instances.