Microsoft/TypeScript
GitHub ã§èŠãCannot access protected field but private field inside nested class
Open
#59,989 opened on 2024幎9æ17æ¥
BugDomain: classesHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð 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