Fix silentNeverType leak through keyof in return type inference#63220
Closed
srobinson wants to merge 1 commit intomicrosoft:mainfrom
Closed
Fix silentNeverType leak through keyof in return type inference#63220srobinson wants to merge 1 commit intomicrosoft:mainfrom
srobinson wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…osoft#62824) When a generic function call is nested inside another generic call, the inner call's type parameters receive silentNeverType as a placeholder during the outer call's inference pass. The keyof operator applied to silentNeverType previously resolved to string | number | symbol via the TypeFlags.Never branch in getIndexType, stripping the NonInferrableType flag and allowing the internal sentinel to leak into user-facing error messages as an unexpected "never". Add an identity check for silentNeverType in getIndexType, matching the existing pattern used for wildcardType. This preserves the sentinel through keyof operations so that NonInferrableType propagation remains intact during mapped type instantiation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree |
Member
|
This is the same as #62825 |
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 #62824
Summary
silentNeverType, an internal sentinel used during nested generic call inference, was leaking into user-facing error messages as an unexpectedneverkeyofoperator ingetIndexTypefell through to theTypeFlags.Neverbranch, resolvingsilentNeverTypetostring | number | symboland stripping itsNonInferrableTypeflagsilentNeverTypeingetIndexType, matching the existingwildcardTypepattern, so the sentinel propagates intact through mapped type instantiationTest plan
silentNeverTypeKeyofLeak.tstest case covering minimal and issue reprosnpx hereby runtests --tests=silentNeverTypeKeyofLeakpasses (6/6)