2484210a00
* If target:esnext,then useDefineForClassFields: true will now be the default. * Added error if a private identifier is used in a static a initializer if target:ESNext and useDefineForClassFields:false. * Added test for new useDefineForClassFields default and error message. * Fixed tests after changing the default of useDefineForClassFields to true for target esnext * Fixed code review suggestions. * Updated error message. * Added missing static check for the containing property. Fixed other code review issues.
45 lines
805 B
TypeScript
45 lines
805 B
TypeScript
//// [privateNameComputedPropertyName3.ts]
|
|
class Foo {
|
|
#name;
|
|
|
|
constructor(name) {
|
|
this.#name = name;
|
|
}
|
|
|
|
getValue(x) {
|
|
const obj = this;
|
|
|
|
class Bar {
|
|
#y = 100;
|
|
|
|
[obj.#name]() {
|
|
return x + this.#y;
|
|
}
|
|
}
|
|
|
|
return new Bar()[obj.#name]();
|
|
}
|
|
}
|
|
|
|
console.log(new Foo("NAME").getValue(100));
|
|
|
|
|
|
//// [privateNameComputedPropertyName3.js]
|
|
class Foo {
|
|
#name;
|
|
constructor(name) {
|
|
this.#name = name;
|
|
}
|
|
getValue(x) {
|
|
const obj = this;
|
|
class Bar {
|
|
#y = 100;
|
|
[obj.#name]() {
|
|
return x + this.#y;
|
|
}
|
|
}
|
|
return new Bar()[obj.#name]();
|
|
}
|
|
}
|
|
console.log(new Foo("NAME").getValue(100));
|