microsoft / microsoft/TypeScript
Misleading error message for `super.instanceProperty`
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic with the TypeScript snippet and inspect where the reported message is defined. Done means the diagnostic clearly explains that an instance property must be accessed through this rather than super, with the proposed quick fix assessed as part of the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100