Skip to content

Commit c600aa7

Browse files
Fix #33732 (#36077)
* Fix #33732 * Remove code change but keep test
1 parent 66aa9e7 commit c600aa7

File tree

5 files changed

+286
-0
lines changed

5 files changed

+286
-0
lines changed

tests/baselines/reference/excessPropertyCheckWithUnions.errors.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,43 @@ tests/cases/compiler/excessPropertyCheckWithUnions.ts(114,63): error TS2322: Typ
192192
const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Error
193193
~
194194
!!! error TS2322: Type 'string' is not assignable to type 'number'.
195+
196+
// Repro from #33732
197+
198+
interface I1 {
199+
prop1: string;
200+
}
201+
202+
interface I2 {
203+
prop2: string;
204+
}
205+
206+
interface I3 extends Record<string, string> {
207+
208+
}
209+
210+
type Properties =
211+
| { [key: string]: never }
212+
| I1
213+
| I2
214+
| I3
215+
;
216+
217+
218+
declare const prop1: string;
219+
declare const prop2: string | undefined;
220+
221+
function F1(_arg: { props: Properties }) { }
222+
F1({
223+
props: {
224+
prop1,
225+
prop2,
226+
},
227+
});
228+
229+
function F2(_props: Properties) { }
230+
F2({
231+
prop1,
232+
prop2,
233+
});
195234

tests/baselines/reference/excessPropertyCheckWithUnions.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,45 @@ const dataSpecification: ObjectDataSpecification = { // Error
113113

114114
const obj1: { [x: string]: number } | { [x: number]: number } = { a: 'abc' }; // Error
115115
const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Error
116+
117+
// Repro from #33732
118+
119+
interface I1 {
120+
prop1: string;
121+
}
122+
123+
interface I2 {
124+
prop2: string;
125+
}
126+
127+
interface I3 extends Record<string, string> {
128+
129+
}
130+
131+
type Properties =
132+
| { [key: string]: never }
133+
| I1
134+
| I2
135+
| I3
136+
;
137+
138+
139+
declare const prop1: string;
140+
declare const prop2: string | undefined;
141+
142+
function F1(_arg: { props: Properties }) { }
143+
F1({
144+
props: {
145+
prop1,
146+
prop2,
147+
},
148+
});
149+
150+
function F2(_props: Properties) { }
151+
F2({
152+
prop1,
153+
prop2,
154+
});
116155

117156

118157
//// [excessPropertyCheckWithUnions.js]
@@ -177,3 +216,15 @@ var dataSpecification = {
177216
// Repro from #34611
178217
var obj1 = { a: 'abc' }; // Error
179218
var obj2 = { a: 5, c: 'abc' }; // Error
219+
function F1(_arg) { }
220+
F1({
221+
props: {
222+
prop1: prop1,
223+
prop2: prop2
224+
}
225+
});
226+
function F2(_props) { }
227+
F2({
228+
prop1: prop1,
229+
prop2: prop2
230+
});

tests/baselines/reference/excessPropertyCheckWithUnions.symbols

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,86 @@ const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Er
310310
>a : Symbol(a, Decl(excessPropertyCheckWithUnions.ts, 113, 55))
311311
>c : Symbol(c, Decl(excessPropertyCheckWithUnions.ts, 113, 61))
312312

313+
// Repro from #33732
314+
315+
interface I1 {
316+
>I1 : Symbol(I1, Decl(excessPropertyCheckWithUnions.ts, 113, 73))
317+
318+
prop1: string;
319+
>prop1 : Symbol(I1.prop1, Decl(excessPropertyCheckWithUnions.ts, 117, 14))
320+
}
321+
322+
interface I2 {
323+
>I2 : Symbol(I2, Decl(excessPropertyCheckWithUnions.ts, 119, 1))
324+
325+
prop2: string;
326+
>prop2 : Symbol(I2.prop2, Decl(excessPropertyCheckWithUnions.ts, 121, 14))
327+
}
328+
329+
interface I3 extends Record<string, string> {
330+
>I3 : Symbol(I3, Decl(excessPropertyCheckWithUnions.ts, 123, 1))
331+
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
332+
333+
}
334+
335+
type Properties =
336+
>Properties : Symbol(Properties, Decl(excessPropertyCheckWithUnions.ts, 127, 1))
337+
338+
| { [key: string]: never }
339+
>key : Symbol(key, Decl(excessPropertyCheckWithUnions.ts, 130, 9))
340+
341+
| I1
342+
>I1 : Symbol(I1, Decl(excessPropertyCheckWithUnions.ts, 113, 73))
343+
344+
| I2
345+
>I2 : Symbol(I2, Decl(excessPropertyCheckWithUnions.ts, 119, 1))
346+
347+
| I3
348+
>I3 : Symbol(I3, Decl(excessPropertyCheckWithUnions.ts, 123, 1))
349+
350+
;
351+
352+
353+
declare const prop1: string;
354+
>prop1 : Symbol(prop1, Decl(excessPropertyCheckWithUnions.ts, 137, 13))
355+
356+
declare const prop2: string | undefined;
357+
>prop2 : Symbol(prop2, Decl(excessPropertyCheckWithUnions.ts, 138, 13))
358+
359+
function F1(_arg: { props: Properties }) { }
360+
>F1 : Symbol(F1, Decl(excessPropertyCheckWithUnions.ts, 138, 40))
361+
>_arg : Symbol(_arg, Decl(excessPropertyCheckWithUnions.ts, 140, 12))
362+
>props : Symbol(props, Decl(excessPropertyCheckWithUnions.ts, 140, 19))
363+
>Properties : Symbol(Properties, Decl(excessPropertyCheckWithUnions.ts, 127, 1))
364+
365+
F1({
366+
>F1 : Symbol(F1, Decl(excessPropertyCheckWithUnions.ts, 138, 40))
367+
368+
props: {
369+
>props : Symbol(props, Decl(excessPropertyCheckWithUnions.ts, 141, 4))
370+
371+
prop1,
372+
>prop1 : Symbol(prop1, Decl(excessPropertyCheckWithUnions.ts, 142, 12))
373+
374+
prop2,
375+
>prop2 : Symbol(prop2, Decl(excessPropertyCheckWithUnions.ts, 143, 14))
376+
377+
},
378+
});
379+
380+
function F2(_props: Properties) { }
381+
>F2 : Symbol(F2, Decl(excessPropertyCheckWithUnions.ts, 146, 3))
382+
>_props : Symbol(_props, Decl(excessPropertyCheckWithUnions.ts, 148, 12))
383+
>Properties : Symbol(Properties, Decl(excessPropertyCheckWithUnions.ts, 127, 1))
384+
385+
F2({
386+
>F2 : Symbol(F2, Decl(excessPropertyCheckWithUnions.ts, 146, 3))
387+
388+
prop1,
389+
>prop1 : Symbol(prop1, Decl(excessPropertyCheckWithUnions.ts, 149, 4))
390+
391+
prop2,
392+
>prop2 : Symbol(prop2, Decl(excessPropertyCheckWithUnions.ts, 150, 10))
393+
394+
});
395+

tests/baselines/reference/excessPropertyCheckWithUnions.types

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,77 @@ const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Er
364364
>c : string
365365
>'abc' : "abc"
366366

367+
// Repro from #33732
368+
369+
interface I1 {
370+
prop1: string;
371+
>prop1 : string
372+
}
373+
374+
interface I2 {
375+
prop2: string;
376+
>prop2 : string
377+
}
378+
379+
interface I3 extends Record<string, string> {
380+
381+
}
382+
383+
type Properties =
384+
>Properties : Properties
385+
386+
| { [key: string]: never }
387+
>key : string
388+
389+
| I1
390+
| I2
391+
| I3
392+
;
393+
394+
395+
declare const prop1: string;
396+
>prop1 : string
397+
398+
declare const prop2: string | undefined;
399+
>prop2 : string | undefined
400+
401+
function F1(_arg: { props: Properties }) { }
402+
>F1 : (_arg: { props: Properties; }) => void
403+
>_arg : { props: Properties; }
404+
>props : Properties
405+
406+
F1({
407+
>F1({ props: { prop1, prop2, },}) : void
408+
>F1 : (_arg: { props: Properties; }) => void
409+
>{ props: { prop1, prop2, },} : { props: { prop1: string; prop2: string | undefined; }; }
410+
411+
props: {
412+
>props : { prop1: string; prop2: string | undefined; }
413+
>{ prop1, prop2, } : { prop1: string; prop2: string | undefined; }
414+
415+
prop1,
416+
>prop1 : string
417+
418+
prop2,
419+
>prop2 : string | undefined
420+
421+
},
422+
});
423+
424+
function F2(_props: Properties) { }
425+
>F2 : (_props: Properties) => void
426+
>_props : Properties
427+
428+
F2({
429+
>F2({ prop1, prop2,}) : void
430+
>F2 : (_props: Properties) => void
431+
>{ prop1, prop2,} : { prop1: string; prop2: string | undefined; }
432+
433+
prop1,
434+
>prop1 : string
435+
436+
prop2,
437+
>prop2 : string | undefined
438+
439+
});
440+

tests/cases/compiler/excessPropertyCheckWithUnions.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,42 @@ const dataSpecification: ObjectDataSpecification = { // Error
113113

114114
const obj1: { [x: string]: number } | { [x: number]: number } = { a: 'abc' }; // Error
115115
const obj2: { [x: string]: number } | { a: number } = { a: 5, c: 'abc' }; // Error
116+
117+
// Repro from #33732
118+
119+
interface I1 {
120+
prop1: string;
121+
}
122+
123+
interface I2 {
124+
prop2: string;
125+
}
126+
127+
interface I3 extends Record<string, string> {
128+
129+
}
130+
131+
type Properties =
132+
| { [key: string]: never }
133+
| I1
134+
| I2
135+
| I3
136+
;
137+
138+
139+
declare const prop1: string;
140+
declare const prop2: string | undefined;
141+
142+
function F1(_arg: { props: Properties }) { }
143+
F1({
144+
props: {
145+
prop1,
146+
prop2,
147+
},
148+
});
149+
150+
function F2(_props: Properties) { }
151+
F2({
152+
prop1,
153+
prop2,
154+
});

0 commit comments

Comments
 (0)