Skip to content

Fixed mapped type modifier propagation when remapping multiple keys to same property#62927

Closed
heathdutton wants to merge 1 commit intomicrosoft:mainfrom
heathdutton:fix/62318-mapped-type-modifier-propagation
Closed

Fixed mapped type modifier propagation when remapping multiple keys to same property#62927
heathdutton wants to merge 1 commit intomicrosoft:mainfrom
heathdutton:fix/62318-mapped-type-modifier-propagation

Conversation

@heathdutton
Copy link

Fixes #62318

Copilot AI review requested due to automatic review settings December 25, 2025 09:02
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Dec 25, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where mapped types with key remapping would produce inconsistent modifier propagation when multiple keys remapped to the same output property name. The behavior was dependent on the order of keys in the source type, which was incorrect.

Key changes:

  • Added logic to merge optional and readonly modifiers when multiple source keys map to the same target property in mapped types
  • Added comprehensive test coverage for both optional and readonly modifier merging scenarios

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/compiler/checker.ts Added logic in addMemberForKeyTypeWorker to merge modifiers (optional/readonly) when an existing property is encountered during mapped type key remapping
tests/cases/compiler/mappedTypeRemappingModifierMerging.ts New test case verifying consistent modifier propagation when multiple keys remap to the same property, testing both optional and readonly modifiers
tests/baselines/reference/mappedTypeRemappingModifierMerging.types Baseline file showing expected type inference for the new test
tests/baselines/reference/mappedTypeRemappingModifierMerging.symbols Baseline file showing expected symbol resolution for the new test
tests/baselines/reference/mappedTypeRemappingModifierMerging.js Baseline file showing expected JavaScript output and declaration files
tests/baselines/reference/mappedTypeRemappingModifierMerging.errors.txt Baseline file showing expected readonly property assignment errors

@heathdutton
Copy link
Author

@microsoft-github-policy-service agree

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
@typescript-bot
Copy link
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

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

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Multiple keys being remapped to same key causes unstable modifier propagation

3 participants