Skip to content

Conversation

@heathdutton
Copy link

Fixes#62318

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

CopilotAI 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
FileDescription
src/compiler/checker.tsAdded logic in addMemberForKeyTypeWorker to merge modifiers (optional/readonly) when an existing property is encountered during mapped type key remapping
tests/cases/compiler/mappedTypeRemappingModifierMerging.tsNew test case verifying consistent modifier propagation when multiple keys remap to the same property, testing both optional and readonly modifiers
tests/baselines/reference/mappedTypeRemappingModifierMerging.typesBaseline file showing expected type inference for the new test
tests/baselines/reference/mappedTypeRemappingModifierMerging.symbolsBaseline file showing expected symbol resolution for the new test
tests/baselines/reference/mappedTypeRemappingModifierMerging.jsBaseline file showing expected JavaScript output and declaration files
tests/baselines/reference/mappedTypeRemappingModifierMerging.errors.txtBaseline file showing expected readonly property assignment errors

@heathdutton
Copy link
Author

@microsoft-github-policy-service agree

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

Labels

For Backlog BugPRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Multiple keys being remapped to same key causes unstable modifier propagation

2 participants

@heathdutton@typescript-bot