File: genericCallWithTupleType.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (59 lines) | stat: -rw-r--r-- 3,281 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
59
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(12,1): error TS2322: Type '[string, number, boolean, boolean]' is not assignable to type '[string, number]'.
  Types of property 'pop' are incompatible.
    Type '() => string | number | boolean' is not assignable to type '() => string | number'.
      Type 'string | number | boolean' is not assignable to type 'string | number'.
        Type 'true' is not assignable to type 'string | number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,1): error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'.
  Type '{ a: string; }' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'.
  Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'.
  Type '{}' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(24,1): error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'.
  Property '1' is missing in type '[{}]'.


==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts (5 errors) ====
    interface I<T, U> {
        tuple1: [T, U];
    } 
    
    var i1: I<string, number>;
    var i2: I<{}, {}>;
    
    // no error
    i1.tuple1 = ["foo", 5];
    var e1 = i1.tuple1[0];  // string
    var e2 = i1.tuple1[1];  // number
    i1.tuple1 = ["foo", 5, false, true];
    ~~~~~~~~~
!!! error TS2322: Type '[string, number, boolean, boolean]' is not assignable to type '[string, number]'.
!!! error TS2322:   Types of property 'pop' are incompatible.
!!! error TS2322:     Type '() => string | number | boolean' is not assignable to type '() => string | number'.
!!! error TS2322:       Type 'string | number | boolean' is not assignable to type 'string | number'.
!!! error TS2322:         Type 'true' is not assignable to type 'string | number'.
    var e3 = i1.tuple1[2];  // {}
    i1.tuple1[3] = { a: "string" };
    ~~~~~~~~~~~~
!!! error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'.
!!! error TS2322:   Type '{ a: string; }' is not assignable to type 'number'.
    var e4 = i1.tuple1[3];  // {}
    i2.tuple1 = ["foo", 5];
    i2.tuple1 = ["foo", "bar"];
    i2.tuple1 = [5, "bar"];
    i2.tuple1 = [{}, {}];
    
    // error
    i1.tuple1 = [5, "foo"];
    ~~~~~~~~~
!!! error TS2322: Type '[number, string]' is not assignable to type '[string, number]'.
!!! error TS2322:   Type 'number' is not assignable to type 'string'.
    i1.tuple1 = [{}, {}];
    ~~~~~~~~~
!!! error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'.
!!! error TS2322:   Type '{}' is not assignable to type 'string'.
    i2.tuple1 = [{}];
    ~~~~~~~~~
!!! error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'.
!!! error TS2322:   Property '1' is missing in type '[{}]'.