Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed isReadonlySymbol check for intersection properties with .valueDeclaration #61346

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Mar 4, 2025

fixes #61344

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Mar 4, 2025
Comment on lines +39012 to +39015
if (checkFlags & CheckFlags.Synthetic) {
// unions and intersections eagerly compute Readonly flag on creation
return !!(checkFlags & CheckFlags.Readonly);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. The issue arised because getDeclarationModifierFlagsFromSymbol(symbol) was returning ModifierFlags.Readonly based on the .valueDeclaration.
  2. .valueDeclaration is only set on union/intersection properties when it's "uniform"(ish). In this example, one source property symbol had a .valueDeclaration and the other one hadn't (the one from the mapped type hadn't it)
  3. but given that, as the existing comment states, the readonly flag is precomputed eagerly for union/intersections - this is really the only thing the compiler has to check in that situation. So I leveraged that for the fix here.

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.

Intersection for same key read-only property maybe wrong
2 participants