Skip to content

Commit 2bc8933

Browse files
committed
Add reproduction test case for #61524
Signed-off-by: moznion <moznion@mail.moznion.net>
1 parent 60e99ec commit 2bc8933

File tree

4 files changed

+200
-0
lines changed

4 files changed

+200
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
issue61524DebugFailureCrash.ts(10,37): error TS2550: Property 'entries' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later.
2+
issue61524DebugFailureCrash.ts(11,9): error TS2769: No overload matches this call.
3+
4+
5+
==== issue61524DebugFailureCrash.ts (2 errors) ====
6+
// Exact reproduction from https://github.com/microsoft/TypeScript/issues/61524
7+
// This code causes "Debug Failure. No error for last overload signature"
8+
9+
type Generic<T> = T extends any[] ? T[number] : T[keyof T];
10+
11+
export function testFn<A extends Record<string, any>>(
12+
obj: A,
13+
cb: (b: Generic<Partial<A>>) => any
14+
) {
15+
for (const [key, val] of Object.entries(obj)) {
16+
~~~~~~~
17+
!!! error TS2550: Property 'entries' does not exist on type 'ObjectConstructor'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later.
18+
cb(val as Generic<A>);
19+
~~
20+
!!! error TS2769: No overload matches this call.
21+
}
22+
}
23+
24+
// Usage that triggers the crash
25+
testFn(
26+
{ foo: "bar", num: 42 },
27+
(val) => console.log(val) // Type inference here causes the issue
28+
);
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//// [tests/cases/compiler/issue61524DebugFailureCrash.ts] ////
2+
3+
=== issue61524DebugFailureCrash.ts ===
4+
// Exact reproduction from https://github.com/microsoft/TypeScript/issues/61524
5+
// This code causes "Debug Failure. No error for last overload signature"
6+
7+
type Generic<T> = T extends any[] ? T[number] : T[keyof T];
8+
>Generic : Symbol(Generic, Decl(issue61524DebugFailureCrash.ts, 0, 0))
9+
>T : Symbol(T, Decl(issue61524DebugFailureCrash.ts, 3, 13))
10+
>T : Symbol(T, Decl(issue61524DebugFailureCrash.ts, 3, 13))
11+
>T : Symbol(T, Decl(issue61524DebugFailureCrash.ts, 3, 13))
12+
>T : Symbol(T, Decl(issue61524DebugFailureCrash.ts, 3, 13))
13+
>T : Symbol(T, Decl(issue61524DebugFailureCrash.ts, 3, 13))
14+
15+
export function testFn<A extends Record<string, any>>(
16+
>testFn : Symbol(testFn, Decl(issue61524DebugFailureCrash.ts, 3, 59))
17+
>A : Symbol(A, Decl(issue61524DebugFailureCrash.ts, 5, 23))
18+
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
19+
20+
obj: A,
21+
>obj : Symbol(obj, Decl(issue61524DebugFailureCrash.ts, 5, 54))
22+
>A : Symbol(A, Decl(issue61524DebugFailureCrash.ts, 5, 23))
23+
24+
cb: (b: Generic<Partial<A>>) => any
25+
>cb : Symbol(cb, Decl(issue61524DebugFailureCrash.ts, 6, 11))
26+
>b : Symbol(b, Decl(issue61524DebugFailureCrash.ts, 7, 9))
27+
>Generic : Symbol(Generic, Decl(issue61524DebugFailureCrash.ts, 0, 0))
28+
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
29+
>A : Symbol(A, Decl(issue61524DebugFailureCrash.ts, 5, 23))
30+
31+
) {
32+
for (const [key, val] of Object.entries(obj)) {
33+
>key : Symbol(key, Decl(issue61524DebugFailureCrash.ts, 9, 16))
34+
>val : Symbol(val, Decl(issue61524DebugFailureCrash.ts, 9, 20))
35+
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
36+
>obj : Symbol(obj, Decl(issue61524DebugFailureCrash.ts, 5, 54))
37+
38+
cb(val as Generic<A>);
39+
>cb : Symbol(cb, Decl(issue61524DebugFailureCrash.ts, 6, 11))
40+
>val : Symbol(val, Decl(issue61524DebugFailureCrash.ts, 9, 20))
41+
>Generic : Symbol(Generic, Decl(issue61524DebugFailureCrash.ts, 0, 0))
42+
>A : Symbol(A, Decl(issue61524DebugFailureCrash.ts, 5, 23))
43+
}
44+
}
45+
46+
// Usage that triggers the crash
47+
testFn(
48+
>testFn : Symbol(testFn, Decl(issue61524DebugFailureCrash.ts, 3, 59))
49+
50+
{ foo: "bar", num: 42 },
51+
>foo : Symbol(foo, Decl(issue61524DebugFailureCrash.ts, 16, 5))
52+
>num : Symbol(num, Decl(issue61524DebugFailureCrash.ts, 16, 17))
53+
54+
(val) => console.log(val) // Type inference here causes the issue
55+
>val : Symbol(val, Decl(issue61524DebugFailureCrash.ts, 17, 5))
56+
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
57+
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
58+
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
59+
>val : Symbol(val, Decl(issue61524DebugFailureCrash.ts, 17, 5))
60+
61+
);
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//// [tests/cases/compiler/issue61524DebugFailureCrash.ts] ////
2+
3+
=== issue61524DebugFailureCrash.ts ===
4+
// Exact reproduction from https://github.com/microsoft/TypeScript/issues/61524
5+
// This code causes "Debug Failure. No error for last overload signature"
6+
7+
type Generic<T> = T extends any[] ? T[number] : T[keyof T];
8+
>Generic : Generic<T>
9+
> : ^^^^^^^^^^
10+
11+
export function testFn<A extends Record<string, any>>(
12+
>testFn : <A extends Record<string, any>>(obj: A, cb: (b: Generic<Partial<A>>) => any) => void
13+
> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^^^^^^^^
14+
15+
obj: A,
16+
>obj : A
17+
> : ^
18+
19+
cb: (b: Generic<Partial<A>>) => any
20+
>cb : (b: Generic<Partial<A>>) => any
21+
> : ^ ^^ ^^^^^
22+
>b : Generic<Partial<A>>
23+
> : ^^^^^^^^^^^^^^^^^^^
24+
25+
) {
26+
for (const [key, val] of Object.entries(obj)) {
27+
>key : any
28+
> : ^^^
29+
>val : any
30+
> : ^^^
31+
>Object.entries(obj) : any
32+
> : ^^^
33+
>Object.entries : any
34+
> : ^^^
35+
>Object : ObjectConstructor
36+
> : ^^^^^^^^^^^^^^^^^
37+
>entries : any
38+
> : ^^^
39+
>obj : A
40+
> : ^
41+
42+
cb(val as Generic<A>);
43+
>cb(val as Generic<A>) : any
44+
> : ^^^
45+
>cb : (b: Generic<Partial<A>>) => any
46+
> : ^ ^^ ^^^^^
47+
>val as Generic<A> : Generic<A>
48+
> : ^^^^^^^^^^
49+
>val : any
50+
> : ^^^
51+
}
52+
}
53+
54+
// Usage that triggers the crash
55+
testFn(
56+
>testFn( { foo: "bar", num: 42 }, (val) => console.log(val) // Type inference here causes the issue) : void
57+
> : ^^^^
58+
>testFn : <A extends Record<string, any>>(obj: A, cb: (b: Generic<Partial<A>>) => any) => void
59+
> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^ ^^^^^^^^^
60+
61+
{ foo: "bar", num: 42 },
62+
>{ foo: "bar", num: 42 } : { foo: string; num: number; }
63+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64+
>foo : string
65+
> : ^^^^^^
66+
>"bar" : "bar"
67+
> : ^^^^^
68+
>num : number
69+
> : ^^^^^^
70+
>42 : 42
71+
> : ^^
72+
73+
(val) => console.log(val) // Type inference here causes the issue
74+
>(val) => console.log(val) : (val: string | number | undefined) => void
75+
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76+
>val : string | number | undefined
77+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
78+
>console.log(val) : void
79+
> : ^^^^
80+
>console.log : (...data: any[]) => void
81+
> : ^^^^ ^^ ^^^^^
82+
>console : Console
83+
> : ^^^^^^^
84+
>log : (...data: any[]) => void
85+
> : ^^^^ ^^ ^^^^^
86+
>val : string | number | undefined
87+
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
88+
89+
);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
// Exact reproduction from https://github.com/microsoft/TypeScript/issues/61524
5+
// This code causes "Debug Failure. No error for last overload signature"
6+
7+
type Generic<T> = T extends any[] ? T[number] : T[keyof T];
8+
9+
export function testFn<A extends Record<string, any>>(
10+
obj: A,
11+
cb: (b: Generic<Partial<A>>) => any
12+
) {
13+
for (const [key, val] of Object.entries(obj)) {
14+
cb(val as Generic<A>);
15+
}
16+
}
17+
18+
// Usage that triggers the crash
19+
testFn(
20+
{ foo: "bar", num: 42 },
21+
(val) => console.log(val) // Type inference here causes the issue
22+
);

0 commit comments

Comments
 (0)