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.
118 lines
2.9 KiB
TypeScript
118 lines
2.9 KiB
TypeScript
//// [privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.ts]
|
|
class TestWithErrors {
|
|
#prop = 0
|
|
static dd = new TestWithErrors().#prop; // Err
|
|
static ["X_ z_ zz"] = class Inner {
|
|
#foo = 10
|
|
m() {
|
|
new TestWithErrors().#prop // Err
|
|
}
|
|
static C = class InnerInner {
|
|
m() {
|
|
new TestWithErrors().#prop // Err
|
|
new Inner().#foo; // Err
|
|
}
|
|
}
|
|
|
|
static M(){
|
|
return class {
|
|
m() {
|
|
new TestWithErrors().#prop // Err
|
|
new Inner().#foo; // OK
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class TestNoErrors {
|
|
#prop = 0
|
|
dd = new TestNoErrors().#prop; // OK
|
|
["X_ z_ zz"] = class Inner {
|
|
#foo = 10
|
|
m() {
|
|
new TestNoErrors().#prop // Ok
|
|
}
|
|
C = class InnerInner {
|
|
m() {
|
|
new TestNoErrors().#prop // Ok
|
|
new Inner().#foo; // Ok
|
|
}
|
|
}
|
|
|
|
static M(){
|
|
return class {
|
|
m() {
|
|
new TestNoErrors().#prop // OK
|
|
new Inner().#foo; // OK
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//// [privateNameErrorsOnNotUseDefineForClassFieldsInEsNext.js]
|
|
"use strict";
|
|
var _a;
|
|
class TestWithErrors {
|
|
constructor() {
|
|
this.#prop = 0;
|
|
}
|
|
#prop;
|
|
}
|
|
TestWithErrors.dd = new TestWithErrors().#prop; // Err
|
|
TestWithErrors["X_ z_ zz"] = (_a = class Inner {
|
|
constructor() {
|
|
this.#foo = 10;
|
|
}
|
|
#foo;
|
|
m() {
|
|
new TestWithErrors().#prop; // Err
|
|
}
|
|
static M() {
|
|
return class {
|
|
m() {
|
|
new TestWithErrors().#prop; // Err
|
|
new Inner().#foo; // OK
|
|
}
|
|
};
|
|
}
|
|
},
|
|
_a.C = class InnerInner {
|
|
m() {
|
|
new TestWithErrors().#prop; // Err
|
|
new _a().#foo; // Err
|
|
}
|
|
},
|
|
_a);
|
|
class TestNoErrors {
|
|
constructor() {
|
|
this.#prop = 0;
|
|
this.dd = new TestNoErrors().#prop; // OK
|
|
this["X_ z_ zz"] = class Inner {
|
|
constructor() {
|
|
this.#foo = 10;
|
|
this.C = class InnerInner {
|
|
m() {
|
|
new TestNoErrors().#prop; // Ok
|
|
new Inner().#foo; // Ok
|
|
}
|
|
};
|
|
}
|
|
#foo;
|
|
m() {
|
|
new TestNoErrors().#prop; // Ok
|
|
}
|
|
static M() {
|
|
return class {
|
|
m() {
|
|
new TestNoErrors().#prop; // OK
|
|
new Inner().#foo; // OK
|
|
}
|
|
};
|
|
}
|
|
};
|
|
}
|
|
#prop;
|
|
}
|