1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
tests/cases/conformance/classes/members/privateNames/privateNamesUnique-3.ts(3,5): error TS18019: 'static' modifier cannot be used with a private identifier.
tests/cases/conformance/classes/members/privateNames/privateNamesUnique-3.ts(3,12): error TS2300: Duplicate identifier '#foo'.
tests/cases/conformance/classes/members/privateNames/privateNamesUnique-3.ts(9,5): error TS18019: 'static' modifier cannot be used with a private identifier.
tests/cases/conformance/classes/members/privateNames/privateNamesUnique-3.ts(11,11): error TS2339: Property '#foo' does not exist on type 'B'.
==== tests/cases/conformance/classes/members/privateNames/privateNamesUnique-3.ts (4 errors) ====
class A {
#foo = 1;
static #foo = true; // error (duplicate)
~~~~~~
!!! error TS18019: 'static' modifier cannot be used with a private identifier.
~~~~
!!! error TS2300: Duplicate identifier '#foo'.
// because static and instance private names
// share the same lexical scope
// https://tc39.es/proposal-class-fields/#prod-ClassBody
}
class B {
static #foo = true;
~~~~~~
!!! error TS18019: 'static' modifier cannot be used with a private identifier.
test(x: B) {
x.#foo; // error (#foo is a static property on B, not an instance property)
~~~~
!!! error TS2339: Property '#foo' does not exist on type 'B'.
}
}
|