• Error
  • Reported by the type checker

TS2415

Class '{0}' incorrectly extends base class '{1}'.

A class doesn't fit the instance type of the class it extends. Fix the member the indented lines point to so it matches the base class.

What it means

A subclass must be usable wherever its base class is expected. When a member is declared in a way that breaks that (a different visibility, an incompatible type, a private member with the same name), the class declaration is reported with indented lines naming the member.

Example

index.ts
class Base {
  protected id = 0;
}
export class Child extends Base {
  private id = 1;
}
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(4,14): error TS2415: Class 'Child' incorrectly extends base class 'Base'.
  Property 'id' is private in type 'Child' but not in type 'Base'.

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

  • Read the indented lines: they name the member and the mismatch.
  • Keep the member's visibility at least as open as in the base class.
  • Give the member a type compatible with the base class's, or rename it if it's a different thing.