File: privateNamesInGenericClasses.errors.txt

package info (click to toggle)
node-typescript 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 396,552 kB
  • sloc: javascript: 1,444,377; makefile: 7; sh: 3
file content (29 lines) | stat: -rw-r--r-- 1,618 bytes parent folder | download
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'.