Skip to content

Commit 386e550

Browse files
committed
Accept new baselines
1 parent f5d6327 commit 386e550

File tree

4 files changed

+189
-1
lines changed

4 files changed

+189
-1
lines changed

tests/baselines/reference/excessPropertyCheckWithUnions.errors.txt

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ tests/cases/compiler/excessPropertyCheckWithUnions.ts(66,9): error TS2322: Type
2626
Object literal may only specify known properties, and 'b' does not exist in type 'AN'.
2727
tests/cases/compiler/excessPropertyCheckWithUnions.ts(87,5): error TS2322: Type '{ tag: "button"; type: "submit"; href: string; }' is not assignable to type 'Union'.
2828
Object literal may only specify known properties, and 'href' does not exist in type 'Button'.
29+
tests/cases/compiler/excessPropertyCheckWithUnions.ts(107,7): error TS2322: Type '{ foo: string; }' is not assignable to type 'ObjectDataSpecification'.
30+
Types of property 'foo' are incompatible.
31+
Type 'string' is not assignable to type 'IValue | undefined'.
32+
tests/cases/compiler/excessPropertyCheckWithUnions.ts(113,7): error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: number; } | { [x: number]: number; }'.
33+
Types of property 'a' are incompatible.
34+
Type 'string' is not assignable to type 'number | undefined'.
35+
tests/cases/compiler/excessPropertyCheckWithUnions.ts(114,7): error TS2322: Type '{ a: number; c: string; }' is not assignable to type '{ [x: string]: number; } | { a: number; }'.
36+
Types of property 'c' are incompatible.
37+
Type 'string' is not assignable to type 'number | undefined'.
2938

3039

31-
==== tests/cases/compiler/excessPropertyCheckWithUnions.ts (11 errors) ====
40+
==== tests/cases/compiler/excessPropertyCheckWithUnions.ts (14 errors) ====
3241
type ADT = {
3342
tag: "A",
3443
a1: string
@@ -157,4 +166,42 @@ tests/cases/compiler/excessPropertyCheckWithUnions.ts(87,5): error TS2322: Type
157166
!!! error TS2322: Type '{ tag: "button"; type: "submit"; href: string; }' is not assignable to type 'Union'.
158167
!!! error TS2322: Object literal may only specify known properties, and 'href' does not exist in type 'Button'.
159168
};
169+
170+
// Repro from #34611
171+
172+
interface IValue {
173+
value: string
174+
}
175+
176+
interface StringKeys {
177+
[propertyName: string]: IValue;
178+
};
179+
180+
interface NumberKeys {
181+
[propertyName: number]: IValue;
182+
}
183+
184+
type ObjectDataSpecification = StringKeys | NumberKeys;
185+
186+
187+
const dataSpecification: ObjectDataSpecification = { // Error
188+
~~~~~~~~~~~~~~~~~
189+
!!! error TS2322: Type '{ foo: string; }' is not assignable to type 'ObjectDataSpecification'.
190+
!!! error TS2322: Types of property 'foo' are incompatible.
191+
!!! error TS2322: Type 'string' is not assignable to type 'IValue | undefined'.
192+
foo: "asdfsadffsd"
193+
};
194+
195+
// Repro from #34611
196+
197+
const obj1: { [x: string]: number } | { [x: number]: number } = { a: 'abc' }; // Error
198+
~~~~
199+
!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ [x: string]: number; } | { [x: number]: number; }'.
200+
!!! error TS2322: Types of property 'a' are incompatible.
201+
!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'.
202+
const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Error
203+
~~~~
204+
!!! error TS2322: Type '{ a: number; c: string; }' is not assignable to type '{ [x: string]: number; } | { a: number; }'.
205+
!!! error TS2322: Types of property 'c' are incompatible.
206+
!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'.
160207

tests/baselines/reference/excessPropertyCheckWithUnions.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,32 @@ const obj: Union = {
8787
// should have error here
8888
href: 'foo',
8989
};
90+
91+
// Repro from #34611
92+
93+
interface IValue {
94+
value: string
95+
}
96+
97+
interface StringKeys {
98+
[propertyName: string]: IValue;
99+
};
100+
101+
interface NumberKeys {
102+
[propertyName: number]: IValue;
103+
}
104+
105+
type ObjectDataSpecification = StringKeys | NumberKeys;
106+
107+
108+
const dataSpecification: ObjectDataSpecification = { // Error
109+
foo: "asdfsadffsd"
110+
};
111+
112+
// Repro from #34611
113+
114+
const obj1: { [x: string]: number } | { [x: number]: number } = { a: 'abc' }; // Error
115+
const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Error
90116

91117

92118
//// [excessPropertyCheckWithUnions.js]
@@ -144,3 +170,10 @@ var obj = {
144170
// should have error here
145171
href: 'foo'
146172
};
173+
;
174+
var dataSpecification = {
175+
foo: "asdfsadffsd"
176+
};
177+
// Repro from #34611
178+
var obj1 = { a: 'abc' }; // Error
179+
var obj2 = { a: 5, c: 'abc' }; // Error

tests/baselines/reference/excessPropertyCheckWithUnions.symbols

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,59 @@ const obj: Union = {
254254

255255
};
256256

257+
// Repro from #34611
258+
259+
interface IValue {
260+
>IValue : Symbol(IValue, Decl(excessPropertyCheckWithUnions.ts, 87, 2))
261+
262+
value: string
263+
>value : Symbol(IValue.value, Decl(excessPropertyCheckWithUnions.ts, 91, 18))
264+
}
265+
266+
interface StringKeys {
267+
>StringKeys : Symbol(StringKeys, Decl(excessPropertyCheckWithUnions.ts, 93, 1))
268+
269+
[propertyName: string]: IValue;
270+
>propertyName : Symbol(propertyName, Decl(excessPropertyCheckWithUnions.ts, 96, 5))
271+
>IValue : Symbol(IValue, Decl(excessPropertyCheckWithUnions.ts, 87, 2))
272+
273+
};
274+
275+
interface NumberKeys {
276+
>NumberKeys : Symbol(NumberKeys, Decl(excessPropertyCheckWithUnions.ts, 97, 2))
277+
278+
[propertyName: number]: IValue;
279+
>propertyName : Symbol(propertyName, Decl(excessPropertyCheckWithUnions.ts, 100, 5))
280+
>IValue : Symbol(IValue, Decl(excessPropertyCheckWithUnions.ts, 87, 2))
281+
}
282+
283+
type ObjectDataSpecification = StringKeys | NumberKeys;
284+
>ObjectDataSpecification : Symbol(ObjectDataSpecification, Decl(excessPropertyCheckWithUnions.ts, 101, 1))
285+
>StringKeys : Symbol(StringKeys, Decl(excessPropertyCheckWithUnions.ts, 93, 1))
286+
>NumberKeys : Symbol(NumberKeys, Decl(excessPropertyCheckWithUnions.ts, 97, 2))
287+
288+
289+
const dataSpecification: ObjectDataSpecification = { // Error
290+
>dataSpecification : Symbol(dataSpecification, Decl(excessPropertyCheckWithUnions.ts, 106, 5))
291+
>ObjectDataSpecification : Symbol(ObjectDataSpecification, Decl(excessPropertyCheckWithUnions.ts, 101, 1))
292+
293+
foo: "asdfsadffsd"
294+
>foo : Symbol(foo, Decl(excessPropertyCheckWithUnions.ts, 106, 52))
295+
296+
};
297+
298+
// Repro from #34611
299+
300+
const obj1: { [x: string]: number } | { [x: number]: number } = { a: 'abc' }; // Error
301+
>obj1 : Symbol(obj1, Decl(excessPropertyCheckWithUnions.ts, 112, 5))
302+
>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 112, 15))
303+
>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 112, 41))
304+
>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 112, 65))
305+
306+
const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Error
307+
>obj2 : Symbol(obj2, Decl(excessPropertyCheckWithUnions.ts, 113, 5))
308+
>x : Symbol(x, Decl(excessPropertyCheckWithUnions.ts, 113, 15))
309+
>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 113, 39))
310+
>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 113, 55))
311+
>c : Symbol(c, Decl(excessPropertyCheckWithUnions.ts, 113, 61))
312+

tests/baselines/reference/excessPropertyCheckWithUnions.types

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,55 @@ const obj: Union = {
312312

313313
};
314314

315+
// Repro from #34611
316+
317+
interface IValue {
318+
value: string
319+
>value : string
320+
}
321+
322+
interface StringKeys {
323+
[propertyName: string]: IValue;
324+
>propertyName : string
325+
326+
};
327+
328+
interface NumberKeys {
329+
[propertyName: number]: IValue;
330+
>propertyName : number
331+
}
332+
333+
type ObjectDataSpecification = StringKeys | NumberKeys;
334+
>ObjectDataSpecification : ObjectDataSpecification
335+
336+
337+
const dataSpecification: ObjectDataSpecification = { // Error
338+
>dataSpecification : ObjectDataSpecification
339+
>{ // Error foo: "asdfsadffsd"} : { foo: string; }
340+
341+
foo: "asdfsadffsd"
342+
>foo : string
343+
>"asdfsadffsd" : "asdfsadffsd"
344+
345+
};
346+
347+
// Repro from #34611
348+
349+
const obj1: { [x: string]: number } | { [x: number]: number } = { a: 'abc' }; // Error
350+
>obj1 : { [x: string]: number; } | { [x: number]: number; }
351+
>x : string
352+
>x : number
353+
>{ a: 'abc' } : { a: string; }
354+
>a : string
355+
>'abc' : "abc"
356+
357+
const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Error
358+
>obj2 : { [x: string]: number; } | { a: number; }
359+
>x : string
360+
>a : number
361+
>{ a: 5, c: 'abc' } : { a: number; c: string; }
362+
>a : number
363+
>5 : 5
364+
>c : string
365+
>'abc' : "abc"
366+

0 commit comments

Comments
 (0)