TS2855

Class field position defined by the parent class is not accessible in the child class via super.

Broken Code ❌

class ChildClass extends ParentClass {
  get isShort() {
    return super.position === ExchangeOrderPosition.SHORT;
  }
}
 
class ParentClass {
  public readonly position: ExchangeOrderPosition;
}

Solution:

This TypeScript error occurs because while super can be used to call parent class methods, it cannot be directly used to access parent class fields. Use this to access the position property inherited from the parent class, rather than using super, which is intended for method invocation.

Fixed Code ✔️

class ChildClass extends ParentClass {
  get isShort() {
    return this.position === ExchangeOrderPosition.SHORT;
  }
}
 
class ParentClass {
  public readonly position: ExchangeOrderPosition;
}