mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 20:25:23 -06:00
Address PR comments
1. Remove extra line in __rest shim. 2. Improve __rest vs __assign check for destructuring assignment.
This commit is contained in:
parent
c9c5f49a24
commit
71f3157a35
@ -1935,10 +1935,18 @@ namespace ts {
|
||||
case SyntaxKind.SpreadElementExpression:
|
||||
case SyntaxKind.JsxSpreadAttribute:
|
||||
let root = container;
|
||||
while (root && root.kind !== SyntaxKind.BinaryExpression) {
|
||||
let hasRest = false;
|
||||
while (root.parent) {
|
||||
if (root.kind === SyntaxKind.ObjectLiteralExpression &&
|
||||
root.parent.kind === SyntaxKind.BinaryExpression &&
|
||||
(root.parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken &&
|
||||
(root.parent as BinaryExpression).left === root) {
|
||||
hasRest = true;
|
||||
break;
|
||||
}
|
||||
root = root.parent;
|
||||
}
|
||||
emitFlags |= root && isDestructuringAssignment(root) ? NodeFlags.HasRestAttribute : NodeFlags.HasSpreadAttribute;
|
||||
emitFlags |= hasRest ? NodeFlags.HasRestAttribute : NodeFlags.HasSpreadAttribute;
|
||||
return;
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
|
||||
@ -45,7 +45,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
const restHelper = `
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p))
|
||||
t[p] = s[p];
|
||||
return t;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user