Skip to content

Commit 86704e5

Browse files
committed
Accept new baselines
1 parent d4f480c commit 86704e5

File tree

4 files changed

+687
-0
lines changed

4 files changed

+687
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(27,20): error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'.
2+
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(28,20): error TS2460: Type 'T2' has no property '2'.
3+
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(31,16): error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'.
4+
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(32,16): error TS2460: Type 'T2' has no property '2'.
5+
tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts(37,18): error TS2733: Index '2' is out-of-bounds in tuple of length 2.
6+
7+
8+
==== tests/cases/conformance/types/tuple/unionsOfTupleTypes1.ts (5 errors) ====
9+
type T1 = [string, number];
10+
type T2 = [boolean] | [string, number];
11+
type T3 = [string, ...number[]];
12+
type T4 = [boolean] | [string, ...number[]];
13+
14+
type T10 = T1[0]; // string
15+
type T11 = T1[1]; // number
16+
type T12 = T1[2]; // undefined
17+
type T1N = T1[number]; // string | number
18+
19+
type T20 = T2[0]; // string | boolean
20+
type T21 = T2[1]; // number | undefined
21+
type T22 = T2[2]; // undefined
22+
type T2N = T2[number]; // string | number | boolean
23+
24+
type T30 = T3[0]; // string
25+
type T31 = T3[1]; // number
26+
type T32 = T3[2]; // number
27+
type T3N = T3[number]; // string | number
28+
29+
type T40 = T4[0]; // string | boolean
30+
type T41 = T4[1]; // number | undefined
31+
type T42 = T4[2]; // number | undefined
32+
type T4N = T4[number]; // string | number | boolean
33+
34+
function f1(t1: T1, t2: T2, t3: T3, t4: T4, x: number) {
35+
let [d10, d11, d12] = t1; // string, number
36+
~~~
37+
!!! error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'.
38+
let [d20, d21, d22] = t2; // string | boolean, number | undefined
39+
~~~
40+
!!! error TS2460: Type 'T2' has no property '2'.
41+
let [d30, d31, d32] = t3; // string, number, number
42+
let [d40, d41, d42] = t4; // string | boolean, number | undefined, number | undefined
43+
[d10, d11, d12] = t1;
44+
~~~
45+
!!! error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'.
46+
[d20, d21, d22] = t2;
47+
~~~
48+
!!! error TS2460: Type 'T2' has no property '2'.
49+
[d30, d31, d32] = t3;
50+
[d40, d41, d42] = t4;
51+
let t10 = t1[0]; // string
52+
let t11 = t1[1]; // number
53+
let t12 = t1[2]; // undefined
54+
~
55+
!!! error TS2733: Index '2' is out-of-bounds in tuple of length 2.
56+
let t1x = t1[x]; // string | number
57+
let t20 = t2[0]; // string | boolean
58+
let t21 = t2[1]; // number | undefined
59+
let t22 = t2[2]; // undefined
60+
let t2x = t2[x]; // string | number | boolean
61+
let t30 = t3[0]; // string
62+
let t31 = t3[1]; // number
63+
let t32 = t3[2]; // number
64+
let t3x = t3[x]; // string | number
65+
let t40 = t4[0]; // string | boolean
66+
let t41 = t4[1]; // number | undefined
67+
let t42 = t4[2]; // number | undefined
68+
let t4x = t4[x]; // string | number | boolean
69+
t1[1] = 42;
70+
t2[1] = 42;
71+
t3[1] = 42;
72+
t4[1] = 42;
73+
}
74+
75+
// Repro from #27543
76+
77+
type Unioned = [string] | [string, number];
78+
const ex: Unioned = ["hi"] as Unioned;
79+
80+
const [x, y] = ex;
81+
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
//// [unionsOfTupleTypes1.ts]
2+
type T1 = [string, number];
3+
type T2 = [boolean] | [string, number];
4+
type T3 = [string, ...number[]];
5+
type T4 = [boolean] | [string, ...number[]];
6+
7+
type T10 = T1[0]; // string
8+
type T11 = T1[1]; // number
9+
type T12 = T1[2]; // undefined
10+
type T1N = T1[number]; // string | number
11+
12+
type T20 = T2[0]; // string | boolean
13+
type T21 = T2[1]; // number | undefined
14+
type T22 = T2[2]; // undefined
15+
type T2N = T2[number]; // string | number | boolean
16+
17+
type T30 = T3[0]; // string
18+
type T31 = T3[1]; // number
19+
type T32 = T3[2]; // number
20+
type T3N = T3[number]; // string | number
21+
22+
type T40 = T4[0]; // string | boolean
23+
type T41 = T4[1]; // number | undefined
24+
type T42 = T4[2]; // number | undefined
25+
type T4N = T4[number]; // string | number | boolean
26+
27+
function f1(t1: T1, t2: T2, t3: T3, t4: T4, x: number) {
28+
let [d10, d11, d12] = t1; // string, number
29+
let [d20, d21, d22] = t2; // string | boolean, number | undefined
30+
let [d30, d31, d32] = t3; // string, number, number
31+
let [d40, d41, d42] = t4; // string | boolean, number | undefined, number | undefined
32+
[d10, d11, d12] = t1;
33+
[d20, d21, d22] = t2;
34+
[d30, d31, d32] = t3;
35+
[d40, d41, d42] = t4;
36+
let t10 = t1[0]; // string
37+
let t11 = t1[1]; // number
38+
let t12 = t1[2]; // undefined
39+
let t1x = t1[x]; // string | number
40+
let t20 = t2[0]; // string | boolean
41+
let t21 = t2[1]; // number | undefined
42+
let t22 = t2[2]; // undefined
43+
let t2x = t2[x]; // string | number | boolean
44+
let t30 = t3[0]; // string
45+
let t31 = t3[1]; // number
46+
let t32 = t3[2]; // number
47+
let t3x = t3[x]; // string | number
48+
let t40 = t4[0]; // string | boolean
49+
let t41 = t4[1]; // number | undefined
50+
let t42 = t4[2]; // number | undefined
51+
let t4x = t4[x]; // string | number | boolean
52+
t1[1] = 42;
53+
t2[1] = 42;
54+
t3[1] = 42;
55+
t4[1] = 42;
56+
}
57+
58+
// Repro from #27543
59+
60+
type Unioned = [string] | [string, number];
61+
const ex: Unioned = ["hi"] as Unioned;
62+
63+
const [x, y] = ex;
64+
65+
66+
//// [unionsOfTupleTypes1.js]
67+
"use strict";
68+
function f1(t1, t2, t3, t4, x) {
69+
var d10 = t1[0], d11 = t1[1], d12 = t1[2]; // string, number
70+
var d20 = t2[0], d21 = t2[1], d22 = t2[2]; // string | boolean, number | undefined
71+
var d30 = t3[0], d31 = t3[1], d32 = t3[2]; // string, number, number
72+
var d40 = t4[0], d41 = t4[1], d42 = t4[2]; // string | boolean, number | undefined, number | undefined
73+
d10 = t1[0], d11 = t1[1], d12 = t1[2];
74+
d20 = t2[0], d21 = t2[1], d22 = t2[2];
75+
d30 = t3[0], d31 = t3[1], d32 = t3[2];
76+
d40 = t4[0], d41 = t4[1], d42 = t4[2];
77+
var t10 = t1[0]; // string
78+
var t11 = t1[1]; // number
79+
var t12 = t1[2]; // undefined
80+
var t1x = t1[x]; // string | number
81+
var t20 = t2[0]; // string | boolean
82+
var t21 = t2[1]; // number | undefined
83+
var t22 = t2[2]; // undefined
84+
var t2x = t2[x]; // string | number | boolean
85+
var t30 = t3[0]; // string
86+
var t31 = t3[1]; // number
87+
var t32 = t3[2]; // number
88+
var t3x = t3[x]; // string | number
89+
var t40 = t4[0]; // string | boolean
90+
var t41 = t4[1]; // number | undefined
91+
var t42 = t4[2]; // number | undefined
92+
var t4x = t4[x]; // string | number | boolean
93+
t1[1] = 42;
94+
t2[1] = 42;
95+
t3[1] = 42;
96+
t4[1] = 42;
97+
}
98+
var ex = ["hi"];
99+
var x = ex[0], y = ex[1];

0 commit comments

Comments
 (0)