Skip to content

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

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

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

@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.

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
@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
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 when importing AssertionError from node:assert/strict

2 participants