Open
Description
Take the following code:
export abstract class YaddaBase {
protected roots = "hi";
}
export class DerivedYadda extends YaddaBase {
public get rootTests() {
return super.roots;
}
}
TypeScript nightly (5.3.0-dev.20230926) reports:
Class field 'roots' defined by the parent class is not accessible in the child class via super.
The error message here is confusing - one might believe that this has to do with accessing a member with a protected modifier, but it is really about accessing an instance field with super
. A better error message would be:
'roots' is defined as an instance property and must be accessed through 'this', not 'super'.
We can also provide a quick fix for this error message.