microsoft / microsoft/TypeScript
Misleading error message for `super.instanceProperty`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere die Diagnose mit dem TypeScript-Snippet und prüfe, wo die gemeldete Nachricht definiert ist. Als erledigt gilt die Aufgabe, wenn die Diagnose klar erklärt, dass auf eine Instanz-Eigenschaft über this statt über super zugegriffen werden muss, und der vorgeschlagene Quick Fix als Teil des Issues bewertet wurde.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100