File: contextualTypeWithTuple.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 (77 lines) | stat: -rw-r--r-- 5,032 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
  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/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'.
  Type '{}' is not assignable to type '{ a: string; }'.
    Property 'a' is missing in type '{}'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(19,1): error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'.
  Property '2' is missing in type '[number, string]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(20,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]'.
  Types of property 'pop' are incompatible.
    Type '() => string | number' is not assignable to type '() => string'.
      Type 'string | number' is not assignable to type 'string'.
        Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(24,1): error TS2322: Type '[C, string | number]' is not assignable to type '[C, string | number, D]'.
  Property '2' is missing in type '[C, string | number]'.
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS2322: Type '[number, string | number]' is not assignable to type '[number, string]'.
  Type 'string | number' is not assignable to type 'string'.
    Type 'number' is not assignable to type 'string'.


==== tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts (7 errors) ====
    // no error
    var numStrTuple: [number, string] = [5, "hello"];
    var numStrTuple2: [number, string] = [5, "foo", true];
        ~~~~~~~~~~~~
!!! error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
!!! 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 numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
    var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
    var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];
    class C { }
    class D { }
    var unionTuple: [C, string | number] = [new C(), "foo"];
    var unionTuple1: [C, string | number] = [new C(), "foo"];
    var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()];
    var unionTuple3: [number, string| number] = [10, "foo"]; 
    
    numStrTuple = numStrTuple2;
    numStrTuple = numStrBoolTuple;
    ~~~~~~~~~~~
!!! error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
    
    // error
    objNumTuple = [ {}, 5];
    ~~~~~~~~~~~
!!! error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'.
!!! error TS2322:   Type '{}' is not assignable to type '{ a: string; }'.
!!! error TS2322:     Property 'a' is missing in type '{}'.
    numStrBoolTuple = numStrTuple;
    ~~~~~~~~~~~~~~~
!!! error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'.
!!! error TS2322:   Property '2' is missing in type '[number, string]'.
    var strStrTuple: [string, string] = ["foo", "bar", 5];
        ~~~~~~~~~~~
!!! error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]'.
!!! error TS2322:   Types of property 'pop' are incompatible.
!!! error TS2322:     Type '() => string | number' is not assignable to type '() => string'.
!!! error TS2322:       Type 'string | number' is not assignable to type 'string'.
!!! error TS2322:         Type 'number' is not assignable to type 'string'.
    
    unionTuple = unionTuple1;
    unionTuple = unionTuple2;
    unionTuple2 = unionTuple;
    ~~~~~~~~~~~
!!! error TS2322: Type '[C, string | number]' is not assignable to type '[C, string | number, D]'.
!!! error TS2322:   Property '2' is missing in type '[C, string | number]'.
    numStrTuple = unionTuple3;
    ~~~~~~~~~~~
!!! error TS2322: Type '[number, string | number]' is not assignable to type '[number, string]'.
!!! error TS2322:   Type 'string | number' is not assignable to type 'string'.
!!! error TS2322:     Type 'number' is not assignable to type 'string'.