File: generics4.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (19 lines) | stat: -rw-r--r-- 832 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
tests/cases/compiler/generics4.ts(7,1): error TS2322: Type 'C<Y>' is not assignable to type 'C<X>'.
  Type 'Y' is not assignable to type 'X'.
    The types returned by 'f()' are incompatible between these types.
      Type 'boolean' is not assignable to type 'string'.


==== tests/cases/compiler/generics4.ts (1 errors) ====
    class C<T> { private x: T; }
    interface X { f(): string; }
    interface Y { f(): boolean; }
    var a: C<X>;
    var b: C<Y>;
    
    a = b; // Not ok - return types of "f" are different
    ~
!!! error TS2322: Type 'C<Y>' is not assignable to type 'C<X>'.
!!! error TS2322:   Type 'Y' is not assignable to type 'X'.
!!! error TS2322:     The types returned by 'f()' are incompatible between these types.
!!! error TS2322:       Type 'boolean' is not assignable to type 'string'.