Skip to content

Commit 71f3157

Browse files
committed
Address PR comments
1. Remove extra line in __rest shim. 2. Improve __rest vs __assign check for destructuring assignment.
1 parent c9c5f49 commit 71f3157

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/compiler/binder.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,10 +1935,18 @@ namespace ts {
19351935
case SyntaxKind.SpreadElementExpression:
19361936
case SyntaxKind.JsxSpreadAttribute:
19371937
let root = container;
1938-
while (root && root.kind !== SyntaxKind.BinaryExpression) {
1938+
let hasRest = false;
1939+
while (root.parent) {
1940+
if (root.kind === SyntaxKind.ObjectLiteralExpression &&
1941+
root.parent.kind === SyntaxKind.BinaryExpression &&
1942+
(root.parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
1943+
(root.parent as BinaryExpression).left === root) {
1944+
hasRest = true;
1945+
break;
1946+
}
19391947
root = root.parent;
19401948
}
1941-
emitFlags |= root && isDestructuringAssignment(root) ? NodeFlags.HasRestAttribute : NodeFlags.HasSpreadAttribute;
1949+
emitFlags |= hasRest ? NodeFlags.HasRestAttribute : NodeFlags.HasSpreadAttribute;
19421950
return;
19431951

19441952
case SyntaxKind.CallSignature:

src/compiler/emitter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
4545
const restHelper = `
4646
var __rest = (this && this.__rest) || function (s, e) {
4747
var t = {};
48-
4948
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p))
5049
t[p] = s[p];
5150
return t;

0 commit comments

Comments
 (0)