Skip to content

Fix Debug Failure crash when importing from mapped type module exports#63141

Closed
veeceey wants to merge 1 commit intomicrosoft:mainfrom
veeceey:fix/issue-58534-debug-failure-mapped-combined-symbol
Closed

Fix Debug Failure crash when importing from mapped type module exports#63141
veeceey wants to merge 1 commit intomicrosoft:mainfrom
veeceey:fix/issue-58534-debug-failure-mapped-combined-symbol

Conversation

@veeceey
Copy link
Copy Markdown

@veeceey veeceey commented Feb 15, 2026

Fixes #58534

Problem

When importing a named export from a module that re-exports via a mapped type (e.g. Omit<typeof ns, never>), the compiler crashes with Error: Debug Failure inside getTypeOfVariableOrParameterOrPropertyWorker.

Minimal reproduction:

// assert.d.ts
declare namespace assert {
  class AssertionError extends Error {}
  const strict: Omit<typeof assert, never>;
}
export = assert.strict;

// index.ts
import { AssertionError } from "./assert";
new AssertionError("assert"); // Debug Failure crash

This also affects real-world code importing AssertionError from node:assert/strict (with @types/node).

Root Cause

combineValueAndTypeSymbols creates a combined symbol for names that resolve to both a value and a type. When the value symbol is a property of a mapped type (has CheckFlags.Mapped), the function was not preserving the mapped symbol's check flags or link properties (mappedType, keyType).

This caused getTypeOfSymbol to skip the CheckFlags.Mapped branch and fall through to getTypeOfVariableOrParameterOrProperty, which then hit Debug.assertIsDefined(symbol.valueDeclaration) — mapped symbols don't have a valueDeclaration, so this crashed.

Fix

Propagate CheckFlags.Mapped and the mapped symbol link properties (mappedType, keyType, nameType, syntheticOrigin) from the value symbol to the combined symbol in combineValueAndTypeSymbols. This ensures getTypeOfSymbol correctly dispatches to getTypeOfMappedSymbol for the combined symbol.

The fix is intentionally conservative — only CheckFlags.Mapped is propagated, not other check flags that might require different symbol link structures.

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Feb 15, 2026
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Feb 15, 2026
@veeceey
Copy link
Copy Markdown
Author

veeceey commented Mar 10, 2026

checking in on this — let me know if there's anything I should update

When a value symbol is a mapped symbol (from a mapped type like Omit<>),
combineValueAndTypeSymbols was losing the mapped symbol's check flags and
link properties (mappedType, keyType). This caused getTypeOfSymbol to
fall through to getTypeOfVariableOrParameterOrProperty, which crashed on
Debug.assertIsDefined(symbol.valueDeclaration) since mapped symbols
don't have a valueDeclaration.

The fix propagates CheckFlags.Mapped and the corresponding mapped symbol
links from the value symbol to the combined symbol, so getTypeOfSymbol
correctly dispatches to getTypeOfMappedSymbol.

Fixes microsoft#58534
@veeceey veeceey force-pushed the fix/issue-58534-debug-failure-mapped-combined-symbol branch from b513518 to 720e1fd Compare March 12, 2026 01:38
@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
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: Done

Development

Successfully merging this pull request may close these issues.

Error: Debug Failure when importing AssertionError from node:assert/strict

2 participants