Skip to content

Commit

Permalink
Fix __spreadArray for non-concat-spreadables (microsoft#45386)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton authored and BobobUnicorn committed Oct 23, 2021
1 parent c2ee202 commit ac6a878
Show file tree
Hide file tree
Showing 52 changed files with 307 additions and 307 deletions.
2 changes: 1 addition & 1 deletion src/compiler/factory/emitHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ namespace ts {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};`
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// In a typed function call, argument expressions are contextually typed by their corresponding parameter types.
function foo(_a) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by
// the type of the property with the numeric name N in the contextual type, if any, or otherwise
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayLiteralSpread.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
function f0() {
var a = [1, 2, 3];
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayLiteralSpreadES5iterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
function f0() {
var a = [1, 2, 3];
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayLiterals2ES5.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// SpreadElement:
// ... AssignmentExpression
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/arrayLiterals3.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// The resulting type an array literal expression is determined as follows:
// - If the array literal contains no spread elements and is contextually typed by a tuple-like type,
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/callChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
o1 === null || o1 === void 0 ? void 0 : o1();
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/callOverload.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var n;
fn(1); // no error
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/callWithSpread.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var _a, _b, _c, _d, _e, _f, _g;
function foo(x, y) {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/callWithSpread2.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// good
all.apply(void 0, ns);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/callWithSpread3.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// error
fs2.apply(void 0, __spreadArray(['a'], s2, false)); // error on ...s2
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/callWithSpread5.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
fn.apply(void 0, __spreadArray(__spreadArray([], nnnu, false), [x], false));
fn.apply(void 0, __spreadArray(__spreadArray([], nntnnnt, false), [x], false));
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
// An expression of type S is considered assignable to an assignment target V if one of the following is true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
// An expression of type S is considered assignable to an assignment target V if one of the following is true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
// S is the type Any, or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
function a1() {
var x = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// The type T associated with a destructuring variable declaration is determined as follows:
// If the declaration includes a type annotation, T is that type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
// The type T associated with a destructuring variable declaration is determined as follows:
// If the declaration includes a type annotation, T is that type.
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/excessiveStackDepthFlatArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
configureStore({
middleware: __spreadArray([], defaultMiddleware, true)
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/excessivelyLargeTupleSpread.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var a0 = [0];
var a1 = __spreadArray(__spreadArray([], a0, true), a0, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
f1();
f1(1, 2);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/genericRestParameters1.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
f1 = f2;
f2 = f1;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/genericRestParameters2.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
f10(42, "hello");
f10(42, "hello", true);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/genericRestParameters3.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
f1("foo", "abc");
f1("foo", 10, true);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/keyofAndIndexedAccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var Shape = /** @class */ (function () {
function Shape() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
function f1() {
var b = true;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/newWithSpread.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
function f(x, y) {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/newWithSpreadES5.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
function f(x, y) {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/noCrashOnNoLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
exports.__esModule = true;
exports.f = void 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
function fn(a, b, c, d, e, f, g) {
var c_1, c_1_1;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/readonlyRestParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
function f0(a, b) {
f0(a, b);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/recursiveReverseMappedType.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
function join(l) {
return __spreadArray(['marker'], l, true);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/recursiveTypeReferences1.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var a0 = 1;
var a1 = [1, [2, 3], [4, [5, [6, 7]]]];
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/restTuplesFromContextualTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
(function (a, b, c) { }).apply(void 0, t1);
(function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/selfReferencingSpreadInLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var additional = [];
for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/spliceTuples.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
var k1;
k1 = __spreadArray([1], sb, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
ar[i] = from[i];
}
}
return to.concat(ar || from);
return to.concat(ar || Array.prototype.slice.call(from));
};
foo1 = __spreadArray([], Array.isArray(foo2) ? foo2 : [foo2], true);
Loading

0 comments on commit ac6a878

Please sign in to comment.