• Error
  • Reported by the type checker

TS2611

'{0}' is defined as a property in class '{1}', but is overridden here in '{2}' as an accessor.

A subclass declares a getter/setter where the base class has a plain property. Use a property in the subclass too, or rename it.

What it means

The base class declares the member as an ordinary property and a subclass redeclares it as an accessor. The base class's field is created on each instance and hides the subclass's accessor.

Example

index.ts
class Base {
  size = 1;
}
class Child extends Base {
  get size(): number { return 2; }
}
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(5,7): error TS2611: 'size' is defined as a property in class 'Base', but is overridden here in 'Child' as an accessor.

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

  • Keep it a property in the subclass, and set it in the constructor if it needs a different value.
  • Or make it an accessor in the base class as well.
  • Or rename one of the two members.