-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed as not planned
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
π Search Terms
abstract, private fields, classes
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about Classes
β― Playground Link
π» Code
abstract class A {
abstract #x: number
getX() {
return this.#x
}
static B = class B extends A {
constructor() {
super()
this.#x = 5
}
}
}
const a = new A.B
console.log(a.getX())This code works as you would expect at runtime (chrome devtools screenshot), since nested static classes can access the same private fields as their containing class.
π Actual behavior
TypeScript errors on line 2 with this message:
'abstract' modifier cannot be used with a private identifier.(18019)
... requiring a ts-expect-error directive.
π Expected behavior
The abstract keyword is allowed.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug