Fix Debug Failure crash when importing from mapped type module exports#63141
Open
veeceey wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix Debug Failure crash when importing from mapped type module exports#63141veeceey wants to merge 1 commit intomicrosoft:mainfrom
veeceey wants to merge 1 commit intomicrosoft:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withError: Debug FailureinsidegetTypeOfVariableOrParameterOrPropertyWorker.Minimal reproduction:
This also affects real-world code importing
AssertionErrorfromnode:assert/strict(with@types/node).Root Cause
combineValueAndTypeSymbolscreates 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 (hasCheckFlags.Mapped), the function was not preserving the mapped symbol's check flags or link properties (mappedType,keyType).This caused
getTypeOfSymbolto skip theCheckFlags.Mappedbranch and fall through togetTypeOfVariableOrParameterOrProperty, which then hitDebug.assertIsDefined(symbol.valueDeclaration)— mapped symbols don't have avalueDeclaration, so this crashed.Fix
Propagate
CheckFlags.Mappedand the mapped symbol link properties (mappedType,keyType,nameType,syntheticOrigin) from the value symbol to the combined symbol incombineValueAndTypeSymbols. This ensuresgetTypeOfSymbolcorrectly dispatches togetTypeOfMappedSymbolfor the combined symbol.The fix is intentionally conservative — only
CheckFlags.Mappedis propagated, not other check flags that might require different symbol link structures.