Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Debug Failure. No error for last overload signature #61524

Open
jens-duttke opened this issue Apr 3, 2025 · 1 comment
Open

Error: Debug Failure. No error for last overload signature #61524

jens-duttke opened this issue Apr 3, 2025 · 1 comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@jens-duttke
Copy link

🔎 Search Terms

The TypeScript compiler crashs with the message "Error: Debug Failure. No error for last overload signature". (Check the DevTools console for the error message in the TypeScript Playground).

I've found issue #60229, which has the same error message. However, I am not sure if the root cause is the same.

🕗 Version & Regression Information

  • The problem appears in the latest nightly version (v5.9.0-dev.20250403)
  • This changed between versions 3.5.1 and 3.6.2 (in the Playground it works in 3.5.1 but not in 3.6.2 anymore)

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250403#code/C4TwDgpgBA4hB2EBOBLAxgHgCoD4oF4osoIAPYBAEwGcoBDeEAbQF0oB+Ip+AVwFsARsjYAuLgGsIIAPYAzIiwDcAKGVkw0pMCiye8NMBTT4UCtWAAxeBgCCJclVoAlCGk2UM51PADmAGnpGHBwACmUoKGkBACsxGz9wqDQBMRCU2ARkdAwABTotFDoAG1tggEoCPAYQZQqAb0TZTSgQt3hzKCZJEACAN2K2OSgAeRjXYAA6BGBUCGoQqOiy+sSI5JD+ovpaOERUTBscMpUIgF9lc6A

💻 Code

type Generic<T> = T extends any[] ? T[number] : T[keyof T];

export function testFn<A extends Record<string, any>>(
  obj: A,
  cb: (b: Generic<Partial<A>>) => any
) {
  for (const [key, val] of Object.entries(obj)) {
    cb(val as Generic<A>);
  }
}

🙁 Actual behavior

The compiler crashs with:

Error: Debug Failure. No error for last overload signature
    at resolveCall (M:\websites\app\node_modules\typescript\lib\_tsc.js:75576:19)
    at resolveCallExpression (M:\websites\app\node_modules\typescript\lib\_tsc.js:75970:12)
    at resolveSignature (M:\websites\app\node_modules\typescript\lib\_tsc.js:76398:16)
    at getResolvedSignature (M:\websites\app\node_modules\typescript\lib\_tsc.js:76425:20)
    at checkCallExpression (M:\websites\app\node_modules\typescript\lib\_tsc.js:76533:23)
    at checkExpressionWorker (M:\websites\app\node_modules\typescript\lib\_tsc.js:79950:16)
    at checkExpression (M:\websites\app\node_modules\typescript\lib\_tsc.js:79849:32)
    at checkExpressionCached (M:\websites\app\node_modules\typescript\lib\_tsc.js:79473:28)
    at checkVariableLikeDeclaration (M:\websites\app\node_modules\typescript\lib\_tsc.js:82311:35)
    at checkVariableDeclaration (M:\websites\app\node_modules\typescript\lib\_tsc.js:82407:5)

🙂 Expected behavior

That the compiler does not crash.

Additional information about the issue

Changing

cb: (b: Generic<Partial<A>>) => any

to

cb: (b: Partial<Generic<A>>) => any

prevents the error. However, this only addresses the symptoms rather than the root cause.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Apr 3, 2025
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Apr 3, 2025
@Andarist
Copy link
Contributor

Andarist commented Apr 5, 2025

At least part of the issue here is that relateVariances differs its behavior on reportErrors. First it fails and returns Ternary.False, exiting the relationship check early~ but then when the compiler looks for errors it returns undefined and continues with the check and it succeeds.

From this angle alone, #55222 would fix this (I checked that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants