Repository navigation
Preserve single evaluation of wrapped compound assignment targets - #65297
Merged
Wesley Wigham (weswigham) merged 4 commits intoNov 4, 2026
Merged
Wesley Wigham (weswigham) merged 4 commits into
Wesley Wigham (weswigham) merged 4 commits into
Conversation
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix downlevel emit evaluating member target twice
Preserve single evaluation of wrapped compound assignment targets
Nov 3, 2026
Ryan Cavanaugh (RyanCavanaugh)
requested a review
from Wesley Wigham (weswigham)
November 3, 2026 22:43
Ryan Cavanaugh (RyanCavanaugh)
marked this pull request as ready for review
November 3, 2026 22:44
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the changes preserving single evaluation of wrapped compound-assignment targets.
No open issues 🎉
What changed in this PR
Addresses #65287 in the native TypeScript compiler by preserving single evaluation of wrapped compound-assignment targets during downlevel emission.
Changes:
- Recognize member targets beneath parentheses and type-erasure wrappers for logical and exponentiation assignments.
- Preserve
superdirectly during exponentiation lowering while caching computed keys. - Add regression coverage across ES2015, ES2020, and ES2021, and update affected conformance baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/compoundAssignmentWithTypeOnlyExpressions.ts |
Tests wrapped property, element, and super targets. |
tsc/testdata/baselines/reference/conformance/compoundExponentiationAssignmentLHSIsValue.js |
Updates expected emit for value targets and super. |
tsc/testdata/baselines/reference/conformance/compoundExponentiationAssignmentLHSIsReference.js |
Records caching for parenthesized member targets. |
tsc/testdata/baselines/reference/compiler/compoundAssignmentWithTypeOnlyExpressions(target=es2021).js |
Records native compound-assignment emit after type erasure. |
tsc/testdata/baselines/reference/compiler/compoundAssignmentWithTypeOnlyExpressions(target=es2020).js |
Records corrected logical-assignment lowering. |
tsc/testdata/baselines/reference/compiler/compoundAssignmentWithTypeOnlyExpressions(target=es2015).js |
Records corrected logical and exponentiation lowering. |
tsc/internal/transformers/estransforms/logicalassignment.go |
Unwraps type-erasure expressions before recognizing targets. |
tsc/internal/transformers/estransforms/exponentiation.go |
Unwraps targets and avoids caching super as a value. |
Review effort: Balanced
Wesley Wigham (weswigham)
approved these changes
Nov 3, 2026
Wesley Wigham (weswigham)
deleted the
copilot/fix-downlevel-emit-logical-assignment
branch
November 4, 2026 00:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65287
Analysis
Type erasure wraps
!,as,satisfies, and angle-bracket assertions inPartiallyEmittedExpression. Downlevel compound-assignment transforms miss the underlying member access, duplicating receiver or key evaluation.Fix
||=,&&=,??=, and**=.superhandling: Preserve the receiver directly while caching computed keys.supertargets across ES2015, ES2020, and ES2021.Copilot Checklist
I successfully ran the applicable command at the end of my session, and it completed without error:
||=,&&=,??=and**=evaluates a member target twice when it has!,asorsatisfies#65287