Bug Report
π Search Terms
accessor backing field
π Version & Regression Information
- I was unable to test this on prior versions because this feature does not exist
β― Playground Link
Playground link with relevant code
π» Code
class Test {
accessor x = 10;
#x_accessor_storage = 11;
method() {
console.log(this.x)
}
}
π Actual behavior
When declaring a private field with the same name as the backing field generated for an accessor by TS, we get a runtime error because we have two private fields with the same name:
class Test {
#x_accessor_storage = 10;
get x() { return this.#x_accessor_storage; }
set x(value) { this.#x_accessor_storage = value; }
#x_accessor_storage = 11;
method() {
console.log(this.x);
}
}
π Expected behavior
The generated field is renamed to avoid conflicts