• Error
  • Reported by the type checker

TS2511

Cannot create an instance of an abstract class.

new is used on an abstract class. Instantiate a concrete subclass instead.

What it means

An abstract class can have members without implementations, so it can't be constructed directly. Only non-abstract subclasses can be created with new.

Example

index.ts
abstract class Shape {
  abstract area(): number;
}
export const s = new Shape();
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(4,18): error TS2511: Cannot create an instance of an abstract class.

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

  • Create an instance of a concrete subclass that implements the abstract members.
  • Remove abstract from the class if it is complete and meant to be instantiated.