Emit [...a] as a.slice() to ensure a is copied
This commit is contained in:
parent
300cb8d9f2
commit
c4b6e64ca6
|
@ -1366,7 +1366,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitListWithSpread(elements: Expression[], multiLine: boolean, trailingComma: boolean) {
|
function emitListWithSpread(elements: Expression[], alwaysCopy: boolean, multiLine: boolean, trailingComma: boolean) {
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
let group = 0;
|
let group = 0;
|
||||||
let length = elements.length;
|
let length = elements.length;
|
||||||
|
@ -1383,6 +1383,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||||
e = (<SpreadElementExpression>e).expression;
|
e = (<SpreadElementExpression>e).expression;
|
||||||
emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e));
|
emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e));
|
||||||
pos++;
|
pos++;
|
||||||
|
if (pos === length && group === 0 && alwaysCopy) {
|
||||||
|
write(".slice()");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let i = pos;
|
let i = pos;
|
||||||
|
@ -1422,7 +1425,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||||
write("]");
|
write("]");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emitListWithSpread(elements, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
|
emitListWithSpread(elements, /*alwaysCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
|
||||||
/*trailingComma*/ elements.hasTrailingComma);
|
/*trailingComma*/ elements.hasTrailingComma);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1847,7 +1850,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||||
write("void 0");
|
write("void 0");
|
||||||
}
|
}
|
||||||
write(", ");
|
write(", ");
|
||||||
emitListWithSpread(node.arguments, /*multiLine*/ false, /*trailingComma*/ false);
|
emitListWithSpread(node.arguments, /*alwaysCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false);
|
||||||
write(")");
|
write(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue