Skip to content

Fix silentNeverType leak through keyof in return type inference#63220

Closed
srobinson wants to merge 1 commit intomicrosoft:mainfrom
srobinson:fix/silent-never-type-keyof-leak-62824
Closed

Fix silentNeverType leak through keyof in return type inference#63220
srobinson wants to merge 1 commit intomicrosoft:mainfrom
srobinson:fix/silent-never-type-keyof-leak-62824

Conversation

@srobinson
Copy link

Fixes #62824

Summary

  • silentNeverType, an internal sentinel used during nested generic call inference, was leaking into user-facing error messages as an unexpected never
  • The keyof operator in getIndexType fell through to the TypeFlags.Never branch, resolving silentNeverType to string | number | symbol and stripping its NonInferrableType flag
  • Added an identity check for silentNeverType in getIndexType, matching the existing wildcardType pattern, so the sentinel propagates intact through mapped type instantiation

Test plan

  • Added silentNeverTypeKeyofLeak.ts test case covering minimal and issue repros
  • npx hereby runtests --tests=silentNeverTypeKeyofLeak passes (6/6)
  • Baselines (.symbols, .types) generated and verified

…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>
@srobinson
Copy link
Author

@microsoft-github-policy-service agree

@jakebailey
Copy link
Member

This is the same as #62825

@jakebailey jakebailey closed this Mar 8, 2026
@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

silentNeverType leak through return type inference

2 participants