Skip to content

Fixed isReadonlySymbol check for intersection properties with .valueDeclaration#61346

Closed
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/readonly-on-intersections
Closed

Fixed isReadonlySymbol check for intersection properties with .valueDeclaration#61346
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/readonly-on-intersections

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

@Andarist Andarist commented Mar 4, 2025

fixes #61344

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Mar 4, 2025
@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
Copy Markdown
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.

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
@typescript-bot
Copy link
Copy Markdown
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.

Intersection for same key read-only property maybe wrong

3 participants