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/privateNamesInGenericClasses.ts(10,3): error TS18013: Property '#foo' is not accessible outside class 'C' because it has a private identifier.
tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(11,1): error TS2322: Type 'C<string>' is not assignable to type 'C<number>'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts(12,1): error TS2322: Type 'C<number>' is not assignable to type 'C<string>'.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/classes/members/privateNames/privateNamesInGenericClasses.ts (3 errors) ====
class C<T> {
#foo: T;
bar(x: C<T>) { return x.#foo; } // OK
baz(x: C<number>) { return x.#foo; } // OK
quux(x: C<string>) { return x.#foo; } // OK
}
declare let a: C<number>;
declare let b: C<string>;
a.#foo; // Error
~~~~
!!! error TS18013: Property '#foo' is not accessible outside class 'C' because it has a private identifier.
a = b; // Error
~
!!! error TS2322: Type 'C<string>' is not assignable to type 'C<number>'.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
b = a; // Error
~
!!! error TS2322: Type 'C<number>' is not assignable to type 'C<string>'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|