Skip to content

Commit 015f4c5

Browse files
committed
Accept new baselines
1 parent 98bbb22 commit 015f4c5

8 files changed

+835
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
tests/cases/conformance/types/intersection/intersectionReduction.ts(40,1): error TS2322: Type 'any' is not assignable to type 'never'.
2+
tests/cases/conformance/types/intersection/intersectionReduction.ts(41,1): error TS2322: Type 'any' is not assignable to type 'never'.
3+
4+
5+
==== tests/cases/conformance/types/intersection/intersectionReduction.ts (2 errors) ====
6+
declare const sym1: unique symbol;
7+
declare const sym2: unique symbol;
8+
9+
type T1 = string & 'a'; // 'a'
10+
type T2 = 'a' & string & 'b'; // never
11+
type T3 = number & 10; // 10
12+
type T4 = 10 & number & 20; // never
13+
type T5 = symbol & typeof sym1; // typeof sym1
14+
type T6 = typeof sym1 & symbol & typeof sym2; // never
15+
type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // never
16+
17+
type T10 = string & ('a' | 'b'); // 'a' | 'b'
18+
type T11 = (string | number) & ('a' | 10); // 'a' | 10
19+
20+
type N1 = 'a' & 'b';
21+
type N2 = { a: string } & null;
22+
type N3 = { a: string } & undefined;
23+
type N4 = string & number;
24+
type N5 = number & object;
25+
type N6 = symbol & string;
26+
type N7 = void & string;
27+
28+
type X = { x: string };
29+
30+
type X1 = X | 'a' & 'b';
31+
type X2 = X | { a: string } & null;
32+
type X3 = X | { a: string } & undefined;
33+
type X4 = X | string & number;
34+
type X5 = X | number & object;
35+
type X6 = X | symbol & string;
36+
type X7 = X | void & string;
37+
38+
// Repro from #31663
39+
40+
const x1 = { a: 'foo', b: 42 };
41+
const x2 = { a: 'foo', b: true };
42+
43+
declare let k: 'a' | 'b';
44+
45+
x1[k] = 'bar' as any; // Error
46+
~~~~~
47+
!!! error TS2322: Type 'any' is not assignable to type 'never'.
48+
x2[k] = 'bar' as any; // Error
49+
~~~~~
50+
!!! error TS2322: Type 'any' is not assignable to type 'never'.
51+
52+
const enum Tag1 {}
53+
const enum Tag2 {}
54+
55+
declare let s1: string & Tag1;
56+
declare let s2: string & Tag2;
57+
58+
declare let t1: string & Tag1 | undefined;
59+
declare let t2: string & Tag2 | undefined;
60+
61+
s1 = s2;
62+
s2 = s1;
63+
64+
t1 = t2;
65+
t2 = t1;
66+

tests/baselines/reference/intersectionReduction.js

+52-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
//// [intersectionReduction.ts]
2-
// @strict
3-
42
declare const sym1: unique symbol;
53
declare const sym2: unique symbol;
64

@@ -14,7 +12,58 @@ type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // never
1412

1513
type T10 = string & ('a' | 'b'); // 'a' | 'b'
1614
type T11 = (string | number) & ('a' | 10); // 'a' | 10
15+
16+
type N1 = 'a' & 'b';
17+
type N2 = { a: string } & null;
18+
type N3 = { a: string } & undefined;
19+
type N4 = string & number;
20+
type N5 = number & object;
21+
type N6 = symbol & string;
22+
type N7 = void & string;
23+
24+
type X = { x: string };
25+
26+
type X1 = X | 'a' & 'b';
27+
type X2 = X | { a: string } & null;
28+
type X3 = X | { a: string } & undefined;
29+
type X4 = X | string & number;
30+
type X5 = X | number & object;
31+
type X6 = X | symbol & string;
32+
type X7 = X | void & string;
33+
34+
// Repro from #31663
35+
36+
const x1 = { a: 'foo', b: 42 };
37+
const x2 = { a: 'foo', b: true };
38+
39+
declare let k: 'a' | 'b';
40+
41+
x1[k] = 'bar' as any; // Error
42+
x2[k] = 'bar' as any; // Error
43+
44+
const enum Tag1 {}
45+
const enum Tag2 {}
46+
47+
declare let s1: string & Tag1;
48+
declare let s2: string & Tag2;
49+
50+
declare let t1: string & Tag1 | undefined;
51+
declare let t2: string & Tag2 | undefined;
52+
53+
s1 = s2;
54+
s2 = s1;
55+
56+
t1 = t2;
57+
t2 = t1;
1758

1859

1960
//// [intersectionReduction.js]
20-
// @strict
61+
// Repro from #31663
62+
var x1 = { a: 'foo', b: 42 };
63+
var x2 = { a: 'foo', b: true };
64+
x1[k] = 'bar'; // Error
65+
x2[k] = 'bar'; // Error
66+
s1 = s2;
67+
s2 = s1;
68+
t1 = t2;
69+
t2 = t1;
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,156 @@
11
=== tests/cases/conformance/types/intersection/intersectionReduction.ts ===
2-
// @strict
3-
42
declare const sym1: unique symbol;
5-
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13))
3+
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 0, 13))
64

75
declare const sym2: unique symbol;
8-
>sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 3, 13))
6+
>sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 1, 13))
97

108
type T1 = string & 'a'; // 'a'
11-
>T1 : Symbol(T1, Decl(intersectionReduction.ts, 3, 34))
9+
>T1 : Symbol(T1, Decl(intersectionReduction.ts, 1, 34))
1210

1311
type T2 = 'a' & string & 'b'; // never
14-
>T2 : Symbol(T2, Decl(intersectionReduction.ts, 5, 23))
12+
>T2 : Symbol(T2, Decl(intersectionReduction.ts, 3, 23))
1513

1614
type T3 = number & 10; // 10
17-
>T3 : Symbol(T3, Decl(intersectionReduction.ts, 6, 29))
15+
>T3 : Symbol(T3, Decl(intersectionReduction.ts, 4, 29))
1816

1917
type T4 = 10 & number & 20; // never
20-
>T4 : Symbol(T4, Decl(intersectionReduction.ts, 7, 22))
18+
>T4 : Symbol(T4, Decl(intersectionReduction.ts, 5, 22))
2119

2220
type T5 = symbol & typeof sym1; // typeof sym1
23-
>T5 : Symbol(T5, Decl(intersectionReduction.ts, 8, 27))
24-
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13))
21+
>T5 : Symbol(T5, Decl(intersectionReduction.ts, 6, 27))
22+
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 0, 13))
2523

2624
type T6 = typeof sym1 & symbol & typeof sym2; // never
27-
>T6 : Symbol(T6, Decl(intersectionReduction.ts, 9, 31))
28-
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13))
29-
>sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 3, 13))
25+
>T6 : Symbol(T6, Decl(intersectionReduction.ts, 7, 31))
26+
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 0, 13))
27+
>sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 1, 13))
3028

3129
type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // never
32-
>T7 : Symbol(T7, Decl(intersectionReduction.ts, 10, 45))
33-
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13))
30+
>T7 : Symbol(T7, Decl(intersectionReduction.ts, 8, 45))
31+
>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 0, 13))
3432

3533
type T10 = string & ('a' | 'b'); // 'a' | 'b'
36-
>T10 : Symbol(T10, Decl(intersectionReduction.ts, 11, 60))
34+
>T10 : Symbol(T10, Decl(intersectionReduction.ts, 9, 60))
3735

3836
type T11 = (string | number) & ('a' | 10); // 'a' | 10
39-
>T11 : Symbol(T11, Decl(intersectionReduction.ts, 13, 32))
37+
>T11 : Symbol(T11, Decl(intersectionReduction.ts, 11, 32))
38+
39+
type N1 = 'a' & 'b';
40+
>N1 : Symbol(N1, Decl(intersectionReduction.ts, 12, 42))
41+
42+
type N2 = { a: string } & null;
43+
>N2 : Symbol(N2, Decl(intersectionReduction.ts, 14, 20))
44+
>a : Symbol(a, Decl(intersectionReduction.ts, 15, 11))
45+
46+
type N3 = { a: string } & undefined;
47+
>N3 : Symbol(N3, Decl(intersectionReduction.ts, 15, 31))
48+
>a : Symbol(a, Decl(intersectionReduction.ts, 16, 11))
49+
50+
type N4 = string & number;
51+
>N4 : Symbol(N4, Decl(intersectionReduction.ts, 16, 36))
52+
53+
type N5 = number & object;
54+
>N5 : Symbol(N5, Decl(intersectionReduction.ts, 17, 26))
55+
56+
type N6 = symbol & string;
57+
>N6 : Symbol(N6, Decl(intersectionReduction.ts, 18, 26))
58+
59+
type N7 = void & string;
60+
>N7 : Symbol(N7, Decl(intersectionReduction.ts, 19, 26))
61+
62+
type X = { x: string };
63+
>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24))
64+
>x : Symbol(x, Decl(intersectionReduction.ts, 22, 10))
65+
66+
type X1 = X | 'a' & 'b';
67+
>X1 : Symbol(X1, Decl(intersectionReduction.ts, 22, 23))
68+
>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24))
69+
70+
type X2 = X | { a: string } & null;
71+
>X2 : Symbol(X2, Decl(intersectionReduction.ts, 24, 24))
72+
>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24))
73+
>a : Symbol(a, Decl(intersectionReduction.ts, 25, 15))
74+
75+
type X3 = X | { a: string } & undefined;
76+
>X3 : Symbol(X3, Decl(intersectionReduction.ts, 25, 35))
77+
>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24))
78+
>a : Symbol(a, Decl(intersectionReduction.ts, 26, 15))
79+
80+
type X4 = X | string & number;
81+
>X4 : Symbol(X4, Decl(intersectionReduction.ts, 26, 40))
82+
>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24))
83+
84+
type X5 = X | number & object;
85+
>X5 : Symbol(X5, Decl(intersectionReduction.ts, 27, 30))
86+
>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24))
87+
88+
type X6 = X | symbol & string;
89+
>X6 : Symbol(X6, Decl(intersectionReduction.ts, 28, 30))
90+
>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24))
91+
92+
type X7 = X | void & string;
93+
>X7 : Symbol(X7, Decl(intersectionReduction.ts, 29, 30))
94+
>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24))
95+
96+
// Repro from #31663
97+
98+
const x1 = { a: 'foo', b: 42 };
99+
>x1 : Symbol(x1, Decl(intersectionReduction.ts, 34, 5))
100+
>a : Symbol(a, Decl(intersectionReduction.ts, 34, 12))
101+
>b : Symbol(b, Decl(intersectionReduction.ts, 34, 22))
102+
103+
const x2 = { a: 'foo', b: true };
104+
>x2 : Symbol(x2, Decl(intersectionReduction.ts, 35, 5))
105+
>a : Symbol(a, Decl(intersectionReduction.ts, 35, 12))
106+
>b : Symbol(b, Decl(intersectionReduction.ts, 35, 22))
107+
108+
declare let k: 'a' | 'b';
109+
>k : Symbol(k, Decl(intersectionReduction.ts, 37, 11))
110+
111+
x1[k] = 'bar' as any; // Error
112+
>x1 : Symbol(x1, Decl(intersectionReduction.ts, 34, 5))
113+
>k : Symbol(k, Decl(intersectionReduction.ts, 37, 11))
114+
115+
x2[k] = 'bar' as any; // Error
116+
>x2 : Symbol(x2, Decl(intersectionReduction.ts, 35, 5))
117+
>k : Symbol(k, Decl(intersectionReduction.ts, 37, 11))
118+
119+
const enum Tag1 {}
120+
>Tag1 : Symbol(Tag1, Decl(intersectionReduction.ts, 40, 21))
121+
122+
const enum Tag2 {}
123+
>Tag2 : Symbol(Tag2, Decl(intersectionReduction.ts, 42, 18))
124+
125+
declare let s1: string & Tag1;
126+
>s1 : Symbol(s1, Decl(intersectionReduction.ts, 45, 11))
127+
>Tag1 : Symbol(Tag1, Decl(intersectionReduction.ts, 40, 21))
128+
129+
declare let s2: string & Tag2;
130+
>s2 : Symbol(s2, Decl(intersectionReduction.ts, 46, 11))
131+
>Tag2 : Symbol(Tag2, Decl(intersectionReduction.ts, 42, 18))
132+
133+
declare let t1: string & Tag1 | undefined;
134+
>t1 : Symbol(t1, Decl(intersectionReduction.ts, 48, 11))
135+
>Tag1 : Symbol(Tag1, Decl(intersectionReduction.ts, 40, 21))
136+
137+
declare let t2: string & Tag2 | undefined;
138+
>t2 : Symbol(t2, Decl(intersectionReduction.ts, 49, 11))
139+
>Tag2 : Symbol(Tag2, Decl(intersectionReduction.ts, 42, 18))
140+
141+
s1 = s2;
142+
>s1 : Symbol(s1, Decl(intersectionReduction.ts, 45, 11))
143+
>s2 : Symbol(s2, Decl(intersectionReduction.ts, 46, 11))
144+
145+
s2 = s1;
146+
>s2 : Symbol(s2, Decl(intersectionReduction.ts, 46, 11))
147+
>s1 : Symbol(s1, Decl(intersectionReduction.ts, 45, 11))
148+
149+
t1 = t2;
150+
>t1 : Symbol(t1, Decl(intersectionReduction.ts, 48, 11))
151+
>t2 : Symbol(t2, Decl(intersectionReduction.ts, 49, 11))
152+
153+
t2 = t1;
154+
>t2 : Symbol(t2, Decl(intersectionReduction.ts, 49, 11))
155+
>t1 : Symbol(t1, Decl(intersectionReduction.ts, 48, 11))
40156

0 commit comments

Comments
 (0)