Skip to content

Conversation

@moznion
Copy link

@moznion moznion commented Nov 21, 2025

Fixes #61524

Replace Debug.fail() calls with proper error generation to prevent TypeScript compiler crashes when overload resolution fails for complex generic constraints, for example JSX elements.

Problem

The TypeScript compiler crashes with "Debug Failure. No error for last overload signature" when resolving certain complex generic constraints, e.g., JSX element types. This regression has existed since TypeScript 3.6 and affects many React/JSX projects.

Root Cause

When getSignatureApplicabilityError() returns no diagnostics for overload candidates, the compiler calls Debug.fail() instead of handling the edge case gracefully, causing an immediate crash.

Solution

  • Replace Debug.fail() calls with fallback diagnostic generation
  • Generate appropriate error messages for unhandled overload resolution cases
  • Ensure compiler continues execution without crashing

Note

This change doesn’t fix the core logic of type inference. Ideally, that core should be fixed, but this pull request only addresses the compiler crash.

Related to #61524, #60229, #48636, #33133

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Nov 21, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Nov 21, 2025
@moznion moznion changed the title Fix compiler crash on JSX overload resolution failure Fix compiler crash on generics overload resolution failure Nov 21, 2025
@moznion
Copy link
Author

moznion commented Nov 21, 2025

@microsoft-github-policy-service agree

@moznion moznion force-pushed the fallback_error_message branch from 0d05479 to b9e3434 Compare November 21, 2025 06:20
…microsoft#61524

Replace `Debug.fail()` calls with proper error generation to prevent TypeScript
compiler crashes when overload resolution fails for complex generic constraints,
for example JSX elements.

Problem
--

The TypeScript compiler crashes with "Debug Failure. No error for last overload
signature" when resolving certain complex generic constraints, e.g., JSX element
types. This regression has existed since TypeScript 3.6 and affects many React/JSX
projects.

Root Cause
--

When `getSignatureApplicabilityError()` returns no diagnostics for overload
candidates, the compiler calls `Debug.fail()` instead of handling the edge case
gracefully, causing an immediate crash.

Solution
--

- Replace `Debug.fail()` calls with fallback diagnostic generation
- Generate appropriate error messages for unhandled overload resolution cases
- Ensure compiler continues execution without crashing

Related to microsoft#61524, microsoft#60229, microsoft#48636, microsoft#33133

Signed-off-by: moznion <[email protected]>
@moznion moznion force-pushed the fallback_error_message branch from b9e3434 to 56578c5 Compare November 21, 2025 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Error: Debug Failure. No error for last overload signature

2 participants