Microsoft/TypeScript
Auf GitHub ansehenCannot access protected field but private field inside nested class
Open
#59.989 geöffnet am 17. Sept. 2024
BugDomain: classesHelp Wanted
Repository-Metriken
- Stars
- (48.455 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)
Beschreibung
🔎 Search Terms
private, protected
🕗 Version & Regression Information
Version 5.6.2
⏯ Playground Link
💻 Code
export class Foo {
protected thisIsProtected = 1;
private thisIsPrivate = 1;
bar():Foo {
const that = this;
return new class extends Foo {
something() {
return that.thisIsPrivate + that.thisIsProtected;
}
}
}
}
🙁 Actual behavior
I get a compile error for that.thisIsProtected, but not for that.thisIsPrivate
🙂 Expected behavior
I can access the protected field, like the private
Additional information about the issue
No response