mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Merge pull request #7970 from Microsoft/fix-transforms-empty-destructuring-assignment
[Transforms] Correct destructuring assignment to empty object
This commit is contained in:
commit
ab49eb9fef
@ -17,10 +17,16 @@ namespace ts {
|
||||
node: BinaryExpression,
|
||||
needsValue: boolean,
|
||||
recordTempVariable: (node: Identifier) => void,
|
||||
visitor?: (node: Node) => VisitResult<Node>) {
|
||||
visitor?: (node: Node) => VisitResult<Node>): Expression {
|
||||
|
||||
if (isEmptyObjectLiteralOrArrayLiteral(node.left)) {
|
||||
return node.right;
|
||||
const right = node.right;
|
||||
if (isDestructuringAssignment(right)) {
|
||||
return flattenDestructuringAssignment(context, right, needsValue, recordTempVariable, visitor);
|
||||
}
|
||||
else {
|
||||
return node.right;
|
||||
}
|
||||
}
|
||||
|
||||
let location: TextRange = node;
|
||||
@ -401,4 +407,4 @@ namespace ts {
|
||||
return emitTempVariableAssignment(value, location);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ let x, y, z, a1, a2, a3;
|
||||
//// [emptyAssignmentPatterns02_ES5.js]
|
||||
var a;
|
||||
var x, y, z, a1, a2, a3;
|
||||
((x = a.x, y = a.y, z = a.z, a));
|
||||
((a1 = a[0], a2 = a[1], a3 = a[2], a));
|
||||
(x = a.x, y = a.y, z = a.z, a);
|
||||
(a1 = a[0], a2 = a[1], a3 = a[2], a);
|
||||
|
||||
|
||||
//// [emptyAssignmentPatterns02_ES5.d.ts]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user