Skip to content

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

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: 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