Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

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:

type Values<T> = T[keyof T];

type Mapped<T> = {
  [K in keyof T as K & string]: {
    src: K;
    logic: T[K];
  };
};

// This would crash or produce incorrect types
type Result = keyof Mapped<SomeType>;

Changes

Impact

Error messages are now more readable:

  • Before: Type 'Mapped6<K>[string] | Mapped6<K>[number] | Mapped6<K>[symbol]' is not assignable to...
  • After: Type 'Mapped6<K>[\_${K}`]' is not assignable to...`

Custom agent used: Strada to Corsa Port Expert
A Go and TypeScript expert who can easily figure out how to port PRs from one language to another

Original prompt

Port microsoft/TypeScript#60528

Custom agent used: Strada to Corsa Port Expert
A Go and TypeScript expert who can easily figure out how to port PRs from one language to another


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 15, 2026 21:34
…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
Copilot AI requested a review from RyanCavanaugh January 15, 2026 21:44
Copy link
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI commented Jan 15, 2026

@copilot also add the new tests from the upstream PR as local tests in this repo

Added two regression tests from the upstream PR in commit 5675e7e:

  • TestKeyRemappingKeyofResult2 for issue #56239
  • TestMappedTypeAsClauseRecursiveNoCrash for issue #60476

Both tests verify that the type checker doesn't crash when processing the complex mapped types that previously caused issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants