Port TypeScript PR #60528: Fix crash on index type deferral for generic mapped types with name types#2519
Closed
Port TypeScript PR #60528: Fix crash on index type deferral for generic mapped types with name types#2519
Conversation
…apped types - Add TypeFlagsIndex to Simplifiable flags - Remove hasDistributiveNameType function - Update shouldDeferIndexType to check for nameType instead - Add getSimplifiedIndexType function - Remove conditional getIndexTypeForMappedType call in checkIndexedAccessIndexType - Update comment about key remapping in getIndexTypeForMappedType Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Port changes from TypeScript PR 60528
Port TypeScript PR #60528: Fix crash on index type deferral for generic mapped types with name types
Jan 15, 2026
RyanCavanaugh
requested changes
Jan 15, 2026
Member
RyanCavanaugh
left a comment
There was a problem hiding this comment.
@copilot also add the new tests from the upstream PR as local tests in this repo
Add two local Go tests for the crash fixes: - TestKeyRemappingKeyofResult2: Tests microsoft/TypeScript#56239 - TestMappedTypeAsClauseRecursiveNoCrash: Tests microsoft/TypeScript#60476 Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Contributor
Author
Added two regression tests from the upstream PR in commit 5675e7e:
Both tests verify that the type checker doesn't crash when processing the complex mapped types that previously caused issues. |
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.
Ports microsoft/TypeScript#60528, which fixes crashes when computing index types for generic mapped types with name types. Previously, the type checker would crash or incorrectly defer index type resolution in cases like:
Changes
TypeFlagsIndexto simplifiable types - Enables simplification of index types for mapped typeshasDistributiveNameTypefunction - The distributive check is no longer needed; simplified to just checking if a name type existsshouldDeferIndexType- Changed from complex distributive checks to simple presence check:getNameTypeFromMappedType(t) != nilgetSimplifiedIndexType- New simplification path for index types on generic mapped types with name types but without keyof constraint declarationscheckIndexedAccessIndexType- Removed conditional logic, now always usesgetIndexTypeExinternal/checker/checker_test.go:TestKeyRemappingKeyofResult2- Validates fix forkeyof FilteringMappedTypecan't compute its constraint TypeScript#56239TestMappedTypeAsClauseRecursiveNoCrash- Validates fix for Regression: Mapped type with recursive key remapping crashes tsc with "RangeError: Maximum call stack size exceeded" in TS@5.4+ TypeScript#60476Impact
Error messages are now more readable:
Type 'Mapped6<K>[string] | Mapped6<K>[number] | Mapped6<K>[symbol]' is not assignable to...Type 'Mapped6<K>[\_${K}`]' is not assignable to...`Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.