microsoft / microsoft/TypeScript
Accessing protected computed property does not produce a compiler error
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔎 Search Terms
protected computed no error bug
🕗 Version & Regression Information
This is the behavior in every version I tried (v3.3.3333, v4.0.5, v5.7.3), and I reviewed the FAQ for entries about Common "Bugs" That Aren't Bugs
⏯ Playground Link
💻 Code
declare class Foo {
protected readonly baz = 42
}
declare class Bar {
readonly foo: Foo
}
declare const bar: Bar
// @ts-expect-error
console.log(bar.foo["baz"].toFixed(2))
🙁 Actual behavior
- (without
// @ts-expect-error): No errors - (with
// @ts-expect-error): Compiler errorUnused '@ts-expect-error' directive
🙂 Expected behavior
- (without
// @ts-expect-error): Compiler errorProperty […] is protected and only accessible within class 'Foo' and its subclasses - (with
// @ts-expect-error): No errors
Additional information about the issue
No response
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 das Verhalten aus dem TypeScript Playground-Link mit dem bereitgestellten Foo-, Bar- und Beispiel für den Zugriff in eckigen Klammern. Beginne damit, die Compiler-Behandlung des Zugriffs auf eine geschützte Eigenschaft über einen indizierten Zugriff nachzuverfolgen, füge dann eine Testabdeckung für die erwartete Diagnose hinzu und überprüfe, dass die @ts-expect-error-Direktive verwendet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100