File: genericAssignmentCompatWithInterfaces1.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (58 lines) | stat: -rw-r--r-- 3,275 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts(12,5): error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
  Types of property 'x' are incompatible.
    Type 'A<number>' is not assignable to type 'Comparable<string>'.
      Types of property 'compareTo' are incompatible.
        Type '(other: number) => number' is not assignable to type '(other: string) => number'.
          Types of parameters 'other' and 'other' are incompatible.
            Type 'string' is not assignable to type 'number'.
tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts(13,5): error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
  Types of property 'x' are incompatible.
    Type 'A<number>' is not assignable to type 'Comparable<string>'.
tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts(16,5): error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
  Types of property 'x' are incompatible.
    Type 'A<number>' is not assignable to type 'Comparable<string>'.
tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts(17,5): error TS2322: Type 'K<number>' is not assignable to type 'I<string>'.
  Types of property 'x' are incompatible.
    Type 'A<number>' is not assignable to type 'Comparable<string>'.


==== tests/cases/compiler/genericAssignmentCompatWithInterfaces1.ts (4 errors) ====
    interface Comparable<T> {
       compareTo(other: T): number;
    }
    interface I<T> {
        x: Comparable<T>;
    }
    interface K<T> {
       x: A<T>;
    }
    class A<T> implements Comparable<T> { compareTo(other: T) { return 1; } }
    var z = { x: new A<number>() };
    var a1: I<string> = { x: new A<number>() };
        ~~
!!! error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
!!! error TS2322:   Types of property 'x' are incompatible.
!!! error TS2322:     Type 'A<number>' is not assignable to type 'Comparable<string>'.
!!! error TS2322:       Types of property 'compareTo' are incompatible.
!!! error TS2322:         Type '(other: number) => number' is not assignable to type '(other: string) => number'.
!!! error TS2322:           Types of parameters 'other' and 'other' are incompatible.
!!! error TS2322:             Type 'string' is not assignable to type 'number'.
    var a2: I<string> = function (): { x: A<number> } {
        ~~
!!! error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
!!! error TS2322:   Types of property 'x' are incompatible.
!!! error TS2322:     Type 'A<number>' is not assignable to type 'Comparable<string>'.
       var z = { x: new A<number>() }; return z;
    } ();
    var a3: I<string> = z;
        ~~
!!! error TS2322: Type '{ x: A<number>; }' is not assignable to type 'I<string>'.
!!! error TS2322:   Types of property 'x' are incompatible.
!!! error TS2322:     Type 'A<number>' is not assignable to type 'Comparable<string>'.
    var a4: I<string> = <K<number>>z;
        ~~
!!! error TS2322: Type 'K<number>' is not assignable to type 'I<string>'.
!!! error TS2322:   Types of property 'x' are incompatible.
!!! error TS2322:     Type 'A<number>' is not assignable to type 'Comparable<string>'.