Skip to content

Commit 513e1f5

Browse files
committed
If the destructuring assignment is synthetic use the left side as source map
This helps in scenarios like below where the assignment is created synthetically for ({a} of {a: string}) { }
1 parent 631e62d commit 513e1f5

5 files changed

Lines changed: 537 additions & 453 deletions

src/compiler/emitter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3955,7 +3955,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
39553955
}
39563956
else if (isAssignmentExpressionStatement) {
39573957
// Source map node for root.left = root.right is root
3958-
emitDestructuringAssignment(target, value, root);
3958+
// but if root is synthetic, which could be in below case, use the target which is { a }
3959+
// for ({a} of {a: string}) {
3960+
// }
3961+
emitDestructuringAssignment(target, value, nodeIsSynthesized(root) ? target : root);
39593962
}
39603963
else {
39613964
if (root.parent.kind !== SyntaxKind.ParenthesizedExpression) {

tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)