File: castingTuple.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (80 lines) | stat: -rw-r--r-- 6,757 bytes parent folder | download | duplicates (3)
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
78
79
80
tests/cases/conformance/types/tuple/castingTuple.ts(13,23): error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Source has 2 element(s) but target requires 3.
tests/cases/conformance/types/tuple/castingTuple.ts(14,15): error TS2352: Conversion of type '[number, string, boolean]' to type '[number, string]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Source has 3 element(s) but target allows only 2.
tests/cases/conformance/types/tuple/castingTuple.ts(15,14): error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
tests/cases/conformance/types/tuple/castingTuple.ts(18,21): error TS2352: Conversion of type '[C, D]' to type '[C, D, A]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Source has 2 element(s) but target requires 3.
tests/cases/conformance/types/tuple/castingTuple.ts(20,33): error TS2493: Tuple type '[C, D, A]' of length '3' has no element at index '5'.
tests/cases/conformance/types/tuple/castingTuple.ts(30,10): error TS2352: Conversion of type '[number, string]' to type '[number, number]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type at position 1 in source is not compatible with type at position 1 in target.
    Type 'string' is not comparable to type 'number'.
tests/cases/conformance/types/tuple/castingTuple.ts(31,10): error TS2352: Conversion of type '[C, D]' to type '[A, I]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type at position 0 in source is not compatible with type at position 0 in target.
    Property 'a' is missing in type 'C' but required in type 'A'.
tests/cases/conformance/types/tuple/castingTuple.ts(32,5): error TS2403: Subsequent variable declarations must have the same type.  Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
tests/cases/conformance/types/tuple/castingTuple.ts(33,1): error TS2304: Cannot find name 't4'.


==== tests/cases/conformance/types/tuple/castingTuple.ts (9 errors) ====
    interface I { }
    class A { a = 10; }
    class C implements I { c };
    class D implements I { d };
    class E extends A { e };
    class F extends A { f };
    enum E1 { one }
    enum E2 { one }
    
    // no error
    var numStrTuple: [number, string] = [5, "foo"];
    var emptyObjTuple = <[{}, {}]>numStrTuple;
    var numStrBoolTuple = <[number, string, boolean]>numStrTuple;
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352:   Source has 2 element(s) but target requires 3.
    var shorter = numStrBoolTuple as [number, string]
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Conversion of type '[number, string, boolean]' to type '[number, string]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352:   Source has 3 element(s) but target allows only 2.
    var longer = numStrTuple as [number, string, boolean]
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
    var classCDTuple: [C, D] = [new C(), new D()];
    var interfaceIITuple = <[I, I]>classCDTuple;
    var classCDATuple = <[C, D, A]>classCDTuple;
                        ~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Conversion of type '[C, D]' to type '[C, D, A]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352:   Source has 2 element(s) but target requires 3.
    var eleFromCDA1 = classCDATuple[2]; // A
    var eleFromCDA2 = classCDATuple[5]; // C | D | A
                                    ~
!!! error TS2493: Tuple type '[C, D, A]' of length '3' has no element at index '5'.
    var t10: [E1, E2] = [E1.one, E2.one];
    var t11 = <[number, number]>t10;
    var array1 = <{}[]>emptyObjTuple;
    var unionTuple: [C, string | number] = [new C(), "foo"];
    var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()];
    var unionTuple3: [number, string| number] = [10, "foo"]; 
    var unionTuple4 = <[number, number]>unionTuple3; 
    
    // error
    var t3 = <[number, number]>numStrTuple;
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Conversion of type '[number, string]' to type '[number, number]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352:   Type at position 1 in source is not compatible with type at position 1 in target.
!!! error TS2352:     Type 'string' is not comparable to type 'number'.
    var t9 = <[A, I]>classCDTuple;
             ~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Conversion of type '[C, D]' to type '[A, I]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
!!! error TS2352:   Type at position 0 in source is not compatible with type at position 0 in target.
!!! error TS2352:     Property 'a' is missing in type 'C' but required in type 'A'.
!!! related TS2728 tests/cases/conformance/types/tuple/castingTuple.ts:2:11: 'a' is declared here.
    var array1 = <number[]>numStrTuple;
        ~~~~~~
!!! error TS2403: Subsequent variable declarations must have the same type.  Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
!!! related TS6203 tests/cases/conformance/types/tuple/castingTuple.ts:23:5: 'array1' was also declared here.
    t4[2] = 10;
    ~~
!!! error TS2304: Cannot find name 't4'.