Skip to content

Commit 97ee951

Browse files
committed
Update baselines
1 parent da6acba commit 97ee951

File tree

2 files changed

+340
-0
lines changed

2 files changed

+340
-0
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
=== tests/cases/compiler/excessPropertyCheckWithUnions.ts ===
2+
type ADT = {
3+
>ADT : Symbol(ADT, Decl(excessPropertyCheckWithUnions.ts, 0, 0))
4+
5+
tag: "A",
6+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 0, 12))
7+
8+
a1: string
9+
>a1 : Symbol(a1, Decl(excessPropertyCheckWithUnions.ts, 1, 13))
10+
11+
} | {
12+
tag: "D",
13+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 3, 5))
14+
15+
d20: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
16+
>d20 : Symbol(d20, Decl(excessPropertyCheckWithUnions.ts, 4, 13))
17+
18+
} | {
19+
tag: "T",
20+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 6, 5))
21+
}
22+
let wrong: ADT = { tag: "T", a1: "extra" }
23+
>wrong : Symbol(wrong, Decl(excessPropertyCheckWithUnions.ts, 9, 3))
24+
>ADT : Symbol(ADT, Decl(excessPropertyCheckWithUnions.ts, 0, 0))
25+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 9, 18))
26+
>a1 : Symbol(a1, Decl(excessPropertyCheckWithUnions.ts, 9, 28))
27+
28+
wrong = { tag: "A", d20: 12 }
29+
>wrong : Symbol(wrong, Decl(excessPropertyCheckWithUnions.ts, 9, 3))
30+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 10, 9))
31+
>d20 : Symbol(d20, Decl(excessPropertyCheckWithUnions.ts, 10, 19))
32+
33+
wrong = { tag: "D" }
34+
>wrong : Symbol(wrong, Decl(excessPropertyCheckWithUnions.ts, 9, 3))
35+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 11, 9))
36+
37+
type Ambiguous = {
38+
>Ambiguous : Symbol(Ambiguous, Decl(excessPropertyCheckWithUnions.ts, 11, 20))
39+
40+
tag: "A",
41+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 13, 18))
42+
43+
x: string
44+
>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 14, 13))
45+
46+
} | {
47+
tag: "A",
48+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 16, 5))
49+
50+
y: number
51+
>y : Symbol(y, Decl(excessPropertyCheckWithUnions.ts, 17, 13))
52+
53+
} | {
54+
tag: "B",
55+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 19, 5))
56+
57+
z: boolean
58+
>z : Symbol(z, Decl(excessPropertyCheckWithUnions.ts, 20, 13))
59+
60+
} | {
61+
tag: "C"
62+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 22, 5))
63+
}
64+
let amb: Ambiguous
65+
>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3))
66+
>Ambiguous : Symbol(Ambiguous, Decl(excessPropertyCheckWithUnions.ts, 11, 20))
67+
68+
// no error for ambiguous tag, even when it could satisfy both constituents at once
69+
amb = { tag: "A", x: "hi" }
70+
>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3))
71+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 27, 7))
72+
>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 27, 17))
73+
74+
amb = { tag: "A", y: 12 }
75+
>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3))
76+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 28, 7))
77+
>y : Symbol(y, Decl(excessPropertyCheckWithUnions.ts, 28, 17))
78+
79+
amb = { tag: "A", x: "hi", y: 12 }
80+
>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3))
81+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 29, 7))
82+
>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 29, 17))
83+
>y : Symbol(y, Decl(excessPropertyCheckWithUnions.ts, 29, 26))
84+
85+
// correctly error on excess property 'extra', even when ambiguous
86+
amb = { tag: "A", x: "hi", extra: 12 }
87+
>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3))
88+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 32, 7))
89+
>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 32, 17))
90+
>extra : Symbol(extra, Decl(excessPropertyCheckWithUnions.ts, 32, 26))
91+
92+
amb = { tag: "A", y: 12, extra: 12 }
93+
>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3))
94+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 33, 7))
95+
>y : Symbol(y, Decl(excessPropertyCheckWithUnions.ts, 33, 17))
96+
>extra : Symbol(extra, Decl(excessPropertyCheckWithUnions.ts, 33, 24))
97+
98+
// assignability errors still work.
99+
// But note that the error for `z: true` is the fallback one of reporting on
100+
// the last constituent since assignability error reporting can't find a single best discriminant either.
101+
amb = { tag: "A" }
102+
>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3))
103+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 38, 7))
104+
105+
amb = { tag: "A", z: true }
106+
>amb : Symbol(amb, Decl(excessPropertyCheckWithUnions.ts, 25, 3))
107+
>tag : Symbol(tag, Decl(excessPropertyCheckWithUnions.ts, 39, 7))
108+
>z : Symbol(z, Decl(excessPropertyCheckWithUnions.ts, 39, 17))
109+
110+
type Overlapping =
111+
>Overlapping : Symbol(Overlapping, Decl(excessPropertyCheckWithUnions.ts, 39, 27))
112+
113+
| { a: 1, b: 1, first: string }
114+
>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 42, 7))
115+
>b : Symbol(b, Decl(excessPropertyCheckWithUnions.ts, 42, 13))
116+
>first : Symbol(first, Decl(excessPropertyCheckWithUnions.ts, 42, 19))
117+
118+
| { a: 2, second: string }
119+
>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 43, 7))
120+
>second : Symbol(second, Decl(excessPropertyCheckWithUnions.ts, 43, 13))
121+
122+
| { b: 3, third: string }
123+
>b : Symbol(b, Decl(excessPropertyCheckWithUnions.ts, 44, 7))
124+
>third : Symbol(third, Decl(excessPropertyCheckWithUnions.ts, 44, 13))
125+
126+
let over: Overlapping
127+
>over : Symbol(over, Decl(excessPropertyCheckWithUnions.ts, 45, 3))
128+
>Overlapping : Symbol(Overlapping, Decl(excessPropertyCheckWithUnions.ts, 39, 27))
129+
130+
// these two are not reported because there are two discriminant properties
131+
over = { a: 1, b: 1, first: "ok", second: "error" }
132+
>over : Symbol(over, Decl(excessPropertyCheckWithUnions.ts, 45, 3))
133+
>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 48, 8))
134+
>b : Symbol(b, Decl(excessPropertyCheckWithUnions.ts, 48, 14))
135+
>first : Symbol(first, Decl(excessPropertyCheckWithUnions.ts, 48, 20))
136+
>second : Symbol(second, Decl(excessPropertyCheckWithUnions.ts, 48, 33))
137+
138+
over = { a: 1, b: 1, first: "ok", third: "error" }
139+
>over : Symbol(over, Decl(excessPropertyCheckWithUnions.ts, 45, 3))
140+
>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 49, 8))
141+
>b : Symbol(b, Decl(excessPropertyCheckWithUnions.ts, 49, 14))
142+
>first : Symbol(first, Decl(excessPropertyCheckWithUnions.ts, 49, 20))
143+
>third : Symbol(third, Decl(excessPropertyCheckWithUnions.ts, 49, 33))
144+
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
=== tests/cases/compiler/excessPropertyCheckWithUnions.ts ===
2+
type ADT = {
3+
>ADT : ADT
4+
5+
tag: "A",
6+
>tag : "A"
7+
8+
a1: string
9+
>a1 : string
10+
11+
} | {
12+
tag: "D",
13+
>tag : "D"
14+
15+
d20: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
16+
>d20 : 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
17+
18+
} | {
19+
tag: "T",
20+
>tag : "T"
21+
}
22+
let wrong: ADT = { tag: "T", a1: "extra" }
23+
>wrong : ADT
24+
>ADT : ADT
25+
>{ tag: "T", a1: "extra" } : { tag: "T"; a1: string; }
26+
>tag : string
27+
>"T" : "T"
28+
>a1 : string
29+
>"extra" : "extra"
30+
31+
wrong = { tag: "A", d20: 12 }
32+
>wrong = { tag: "A", d20: 12 } : { tag: "A"; d20: 12; }
33+
>wrong : ADT
34+
>{ tag: "A", d20: 12 } : { tag: "A"; d20: 12; }
35+
>tag : string
36+
>"A" : "A"
37+
>d20 : number
38+
>12 : 12
39+
40+
wrong = { tag: "D" }
41+
>wrong = { tag: "D" } : { tag: "D"; }
42+
>wrong : ADT
43+
>{ tag: "D" } : { tag: "D"; }
44+
>tag : string
45+
>"D" : "D"
46+
47+
type Ambiguous = {
48+
>Ambiguous : Ambiguous
49+
50+
tag: "A",
51+
>tag : "A"
52+
53+
x: string
54+
>x : string
55+
56+
} | {
57+
tag: "A",
58+
>tag : "A"
59+
60+
y: number
61+
>y : number
62+
63+
} | {
64+
tag: "B",
65+
>tag : "B"
66+
67+
z: boolean
68+
>z : boolean
69+
70+
} | {
71+
tag: "C"
72+
>tag : "C"
73+
}
74+
let amb: Ambiguous
75+
>amb : Ambiguous
76+
>Ambiguous : Ambiguous
77+
78+
// no error for ambiguous tag, even when it could satisfy both constituents at once
79+
amb = { tag: "A", x: "hi" }
80+
>amb = { tag: "A", x: "hi" } : { tag: "A"; x: string; }
81+
>amb : Ambiguous
82+
>{ tag: "A", x: "hi" } : { tag: "A"; x: string; }
83+
>tag : string
84+
>"A" : "A"
85+
>x : string
86+
>"hi" : "hi"
87+
88+
amb = { tag: "A", y: 12 }
89+
>amb = { tag: "A", y: 12 } : { tag: "A"; y: number; }
90+
>amb : Ambiguous
91+
>{ tag: "A", y: 12 } : { tag: "A"; y: number; }
92+
>tag : string
93+
>"A" : "A"
94+
>y : number
95+
>12 : 12
96+
97+
amb = { tag: "A", x: "hi", y: 12 }
98+
>amb = { tag: "A", x: "hi", y: 12 } : { tag: "A"; x: string; y: number; }
99+
>amb : Ambiguous
100+
>{ tag: "A", x: "hi", y: 12 } : { tag: "A"; x: string; y: number; }
101+
>tag : string
102+
>"A" : "A"
103+
>x : string
104+
>"hi" : "hi"
105+
>y : number
106+
>12 : 12
107+
108+
// correctly error on excess property 'extra', even when ambiguous
109+
amb = { tag: "A", x: "hi", extra: 12 }
110+
>amb = { tag: "A", x: "hi", extra: 12 } : { tag: "A"; x: string; extra: number; }
111+
>amb : Ambiguous
112+
>{ tag: "A", x: "hi", extra: 12 } : { tag: "A"; x: string; extra: number; }
113+
>tag : string
114+
>"A" : "A"
115+
>x : string
116+
>"hi" : "hi"
117+
>extra : number
118+
>12 : 12
119+
120+
amb = { tag: "A", y: 12, extra: 12 }
121+
>amb = { tag: "A", y: 12, extra: 12 } : { tag: "A"; y: number; extra: number; }
122+
>amb : Ambiguous
123+
>{ tag: "A", y: 12, extra: 12 } : { tag: "A"; y: number; extra: number; }
124+
>tag : string
125+
>"A" : "A"
126+
>y : number
127+
>12 : 12
128+
>extra : number
129+
>12 : 12
130+
131+
// assignability errors still work.
132+
// But note that the error for `z: true` is the fallback one of reporting on
133+
// the last constituent since assignability error reporting can't find a single best discriminant either.
134+
amb = { tag: "A" }
135+
>amb = { tag: "A" } : { tag: "A"; }
136+
>amb : Ambiguous
137+
>{ tag: "A" } : { tag: "A"; }
138+
>tag : string
139+
>"A" : "A"
140+
141+
amb = { tag: "A", z: true }
142+
>amb = { tag: "A", z: true } : { tag: "A"; z: true; }
143+
>amb : Ambiguous
144+
>{ tag: "A", z: true } : { tag: "A"; z: true; }
145+
>tag : string
146+
>"A" : "A"
147+
>z : boolean
148+
>true : true
149+
150+
type Overlapping =
151+
>Overlapping : Overlapping
152+
153+
| { a: 1, b: 1, first: string }
154+
>a : 1
155+
>b : 1
156+
>first : string
157+
158+
| { a: 2, second: string }
159+
>a : 2
160+
>second : string
161+
162+
| { b: 3, third: string }
163+
>b : 3
164+
>third : string
165+
166+
let over: Overlapping
167+
>over : Overlapping
168+
>Overlapping : Overlapping
169+
170+
// these two are not reported because there are two discriminant properties
171+
over = { a: 1, b: 1, first: "ok", second: "error" }
172+
>over = { a: 1, b: 1, first: "ok", second: "error" } : { a: 1; b: 1; first: string; second: string; }
173+
>over : Overlapping
174+
>{ a: 1, b: 1, first: "ok", second: "error" } : { a: 1; b: 1; first: string; second: string; }
175+
>a : number
176+
>1 : 1
177+
>b : number
178+
>1 : 1
179+
>first : string
180+
>"ok" : "ok"
181+
>second : string
182+
>"error" : "error"
183+
184+
over = { a: 1, b: 1, first: "ok", third: "error" }
185+
>over = { a: 1, b: 1, first: "ok", third: "error" } : { a: 1; b: 1; first: string; third: string; }
186+
>over : Overlapping
187+
>{ a: 1, b: 1, first: "ok", third: "error" } : { a: 1; b: 1; first: string; third: string; }
188+
>a : number
189+
>1 : 1
190+
>b : number
191+
>1 : 1
192+
>first : string
193+
>"ok" : "ok"
194+
>third : string
195+
>"error" : "error"
196+

0 commit comments

Comments
 (0)