Port TS#60528: Fix index type deferral crash on generic mapped types with name types#2750
Merged
jakebailey merged 2 commits intomainfrom Feb 12, 2026
Merged
Conversation
…n generic mapped types with name types Changes: - Simplify shouldDeferIndexType to check for name type existence instead of distributive name type - Remove hasDistributiveNameType function (no longer needed) - Add TypeFlagsIndex to TypeFlagsSimplifiable - Handle generic mapped types with name types in computeBaseConstraint - Route TypeFlagsIndex through getResolvedBaseConstraint in getBaseConstraintOfType - Unskip mappedTypeAsClauseRecursiveNoCrash1.ts test - Accept baseline changes Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix crash related to index type deferral on generic mapped types
Port TS#60528: Fix index type deferral crash on generic mapped types with name types
Feb 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Ports TypeScript PR #60528 to prevent crashes and improve constraint computation for index types on generic mapped types that use as clause name types.
Changes:
- Adjust index-type deferral for generic mapped types with
asclauses and remove obsolete distributive-name-type logic. - Improve base-constraint resolution for
TypeFlagsIndexwhen targeting certain generic mapped types with name types. - Re-enable the
mappedTypeAsClauseRecursiveNoCrash1.tsregression test and update affected baselines.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/checker/checker.go | Updates deferral/base-constraint logic for index types involving generic mapped types; removes hasDistributiveNameType. |
| internal/checker/types.go | Adds TypeFlagsIndex to TypeFlagsSimplifiable so index types participate in simplification/constraint flows. |
| internal/testrunner/compiler_runner.go | Unskips mappedTypeAsClauseRecursiveNoCrash1.ts. |
| testdata/baselines/reference/submodule/conformance/mappedTypeConstraints2.* | Updates baselines for mapped type constraint and error output changes. |
| testdata/baselines/reference/submodule/conformance/mappedTypeAsClauseRecursiveNoCrash1.* | Adds new baseline outputs for the re-enabled regression test. |
| testdata/baselines/reference/submodule/compiler/keyRemappingKeyofResult2.errors.txt* | Removes baseline error output (now empty/no longer applicable). |
Comments suppressed due to low confidence (2)
internal/checker/checker.go:1
- This comment now states there is 'a key remapping', but the condition guarding it is
isMappedTypeWithKeyofConstraintDeclaration(t)plus a generic index constraint; that doesn’t necessarily imply anas-clause remapping is present. Consider rewording the comment to describe the actual condition (generic index + homomorphic mapping viakeyofconstraint) or tighten the code to only enter this path when a name type exists (e.g.,getNameTypeFromMappedType(t) != nil) if that’s what the comment intends.
internal/checker/checker.go:1 - This block calls
t.AsIndexType()twice and repeats.targetaccess. Consider storingindex := t.AsIndexType()andmappedType := index.targetonce to make the control flow clearer and avoid duplicated accessor calls.
RyanCavanaugh
approved these changes
Feb 12, 2026
Copilot AI
added a commit
that referenced
this pull request
Feb 25, 2026
…with name types (#2750) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
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. Generic mapped types with
asclause name types could crash when computing index types due to incorrect deferral logic and missing base constraint handling.Changes
shouldDeferIndexType: Simplify condition from!hasDistributiveNameType(t) || getMappedTypeNameTypeKind(t) == RemappingtogetNameTypeFromMappedType(t) != nil— any generic mapped type with anasclause now defershasDistributiveNameType: No longer referenced after the above simplificationcomputeBaseConstraint: ForTypeFlagsIndextargeting a generic mapped type with a name type (non-homomorphic), recursively compute base constraint from the mapped type's index type instead of unconditionally returningstringNumberSymbolTypegetBaseConstraintOfType: RouteTypeFlagsIndexthroughgetResolvedBaseConstraintinstead of short-circuitingTypeFlagsSimplifiable: AddTypeFlagsIndexto the flag setmappedTypeAsClauseRecursiveNoCrash1.tstest✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.