File: unionsOfTupleTypes1.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (90 lines) | stat: -rw-r--r-- 4,212 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
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
81
82
83
84
85
86
87
88
89
90
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(8,15): error TS2493: Tuple type 'T1' of length '2' has no element at index '2'.
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(13,15): error TS2339: Property '2' does not exist on type 'T2'.
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(27,20): error TS2493: Tuple type 'T1' of length '2' has no element at index '2'.
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(28,20): error TS2339: Property '2' does not exist on type 'T2'.
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(31,16): error TS2493: Tuple type 'T1' of length '2' has no element at index '2'.
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(32,16): error TS2339: Property '2' does not exist on type 'T2'.
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(37,18): error TS2493: Tuple type 'T1' of length '2' has no element at index '2'.
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(41,18): error TS2339: Property '2' does not exist on type 'T2'.


==== tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts (8 errors) ====
    type T1 = [string, number];
    type T2 = [boolean] | [string, number];
    type T3 = [string, ...number[]];
    type T4 = [boolean] | [string, ...number[]];
    
    type T10 = T1[0];  // string
    type T11 = T1[1];  // number
    type T12 = T1[2];  // undefined
                  ~
!!! error TS2493: Tuple type 'T1' of length '2' has no element at index '2'.
    type T1N = T1[number];  // string | number
    
    type T20 = T2[0];  // string | boolean
    type T21 = T2[1];  // number | undefined
    type T22 = T2[2];  // undefined
                  ~
!!! error TS2339: Property '2' does not exist on type 'T2'.
    type T2N = T2[number];  // string | number | boolean
    
    type T30 = T3[0];  // string
    type T31 = T3[1];  // number
    type T32 = T3[2];  // number
    type T3N = T3[number];  // string | number
    
    type T40 = T4[0];  // string | boolean
    type T41 = T4[1];  // number | undefined
    type T42 = T4[2];  // number | undefined
    type T4N = T4[number];  // string | number | boolean
    
    function f1(t1: T1, t2: T2, t3: T3, t4: T4, x: number) {
        let [d10, d11, d12] = t1;  // string, number
                       ~~~
!!! error TS2493: Tuple type 'T1' of length '2' has no element at index '2'.
        let [d20, d21, d22] = t2;  // string | boolean, number | undefined
                       ~~~
!!! error TS2339: Property '2' does not exist on type 'T2'.
        let [d30, d31, d32] = t3;  // string, number, number
        let [d40, d41, d42] = t4;  // string | boolean, number | undefined, number | undefined
        [d10, d11, d12] = t1;
                   ~~~
!!! error TS2493: Tuple type 'T1' of length '2' has no element at index '2'.
        [d20, d21, d22] = t2;
                   ~~~
!!! error TS2339: Property '2' does not exist on type 'T2'.
        [d30, d31, d32] = t3;
        [d40, d41, d42] = t4;
        let t10 = t1[0];  // string
        let t11 = t1[1];  // number
        let t12 = t1[2];  // undefined
                     ~
!!! error TS2493: Tuple type 'T1' of length '2' has no element at index '2'.
        let t1x = t1[x];  // string | number
        let t20 = t2[0];  // string | boolean
        let t21 = t2[1];  // number | undefined
        let t22 = t2[2];  // undefined
                     ~
!!! error TS2339: Property '2' does not exist on type 'T2'.
        let t2x = t2[x];  // string | number | boolean
        let t30 = t3[0];  // string
        let t31 = t3[1];  // number
        let t32 = t3[2];  // number
        let t3x = t3[x];  // string | number
        let t40 = t4[0];  // string | boolean
        let t41 = t4[1];  // number | undefined
        let t42 = t4[2];  // number | undefined
        let t4x = t4[x];  // string | number | boolean
        t1[1] = 42;
        t2[1] = 42;
        t3[1] = 42;
        t4[1] = 42;
    }
    
    // Repro from #27543
    
    type Unioned = [string] | [string, number];
    const ex: Unioned = ["hi"] as Unioned;
    
    const [x, y] = ex;