1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
tests/cases/conformance/classes/members/privateNames/privateNameMethodClassExpression.ts(9,17): error TS18013: Property '#method' is not accessible outside class '(anonymous)' because it has a private identifier.
tests/cases/conformance/classes/members/privateNames/privateNameMethodClassExpression.ts(10,17): error TS18013: Property '#field' is not accessible outside class '(anonymous)' because it has a private identifier.
==== tests/cases/conformance/classes/members/privateNames/privateNameMethodClassExpression.ts (2 errors) ====
const C = class {
#field = this.#method();
#method() { return 42; }
static getInstance() { return new C(); }
getField() { return this.#field };
}
console.log(C.getInstance().getField());
C.getInstance().#method; // Error
~~~~~~~
!!! error TS18013: Property '#method' is not accessible outside class '(anonymous)' because it has a private identifier.
C.getInstance().#field; // Error
~~~~~~
!!! error TS18013: Property '#field' is not accessible outside class '(anonymous)' because it has a private identifier.
|