Skip to content

Commit e9b1ff5

Browse files
authored
Fix __spreadArray for non-concat-spreadables (#45386)
1 parent 11339d9 commit e9b1ff5

File tree

52 files changed

+307
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+307
-307
lines changed

src/compiler/factory/emitHelpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ namespace ts {
647647
ar[i] = from[i];
648648
}
649649
}
650-
return to.concat(ar || from);
650+
return to.concat(ar || Array.prototype.slice.call(from));
651651
};`
652652
};
653653

tests/baselines/reference/argumentExpressionContextualTyping.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2626
ar[i] = from[i];
2727
}
2828
}
29-
return to.concat(ar || from);
29+
return to.concat(ar || Array.prototype.slice.call(from));
3030
};
3131
// In a typed function call, argument expressions are contextually typed by their corresponding parameter types.
3232
function foo(_a) {

tests/baselines/reference/arrayLiteralExpressionContextualTyping.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2323
ar[i] = from[i];
2424
}
2525
}
26-
return to.concat(ar || from);
26+
return to.concat(ar || Array.prototype.slice.call(from));
2727
};
2828
// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by
2929
// the type of the property with the numeric name N in the contextual type, if any, or otherwise

tests/baselines/reference/arrayLiteralSpread.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3131
ar[i] = from[i];
3232
}
3333
}
34-
return to.concat(ar || from);
34+
return to.concat(ar || Array.prototype.slice.call(from));
3535
};
3636
function f0() {
3737
var a = [1, 2, 3];

tests/baselines/reference/arrayLiteralSpreadES5iterable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4747
ar[i] = from[i];
4848
}
4949
}
50-
return to.concat(ar || from);
50+
return to.concat(ar || Array.prototype.slice.call(from));
5151
};
5252
function f0() {
5353
var a = [1, 2, 3];

tests/baselines/reference/arrayLiterals2ES5.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
6969
ar[i] = from[i];
7070
}
7171
}
72-
return to.concat(ar || from);
72+
return to.concat(ar || Array.prototype.slice.call(from));
7373
};
7474
// SpreadElement:
7575
// ... AssignmentExpression

tests/baselines/reference/arrayLiterals3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4747
ar[i] = from[i];
4848
}
4949
}
50-
return to.concat(ar || from);
50+
return to.concat(ar || Array.prototype.slice.call(from));
5151
};
5252
// The resulting type an array literal expression is determined as follows:
5353
// - If the array literal contains no spread elements and is contextually typed by a tuple-like type,

tests/baselines/reference/callChain.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
5050
ar[i] = from[i];
5151
}
5252
}
53-
return to.concat(ar || from);
53+
return to.concat(ar || Array.prototype.slice.call(from));
5454
};
5555
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
5656
o1 === null || o1 === void 0 ? void 0 : o1();

tests/baselines/reference/callOverload.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1919
ar[i] = from[i];
2020
}
2121
}
22-
return to.concat(ar || from);
22+
return to.concat(ar || Array.prototype.slice.call(from));
2323
};
2424
var n;
2525
fn(1); // no error

tests/baselines/reference/callWithSpread.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8181
ar[i] = from[i];
8282
}
8383
}
84-
return to.concat(ar || from);
84+
return to.concat(ar || Array.prototype.slice.call(from));
8585
};
8686
var _a, _b, _c, _d, _e, _f, _g;
8787
function foo(x, y) {

tests/baselines/reference/callWithSpread2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4545
ar[i] = from[i];
4646
}
4747
}
48-
return to.concat(ar || from);
48+
return to.concat(ar || Array.prototype.slice.call(from));
4949
};
5050
// good
5151
all.apply(void 0, ns);

tests/baselines/reference/callWithSpread3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4444
ar[i] = from[i];
4545
}
4646
}
47-
return to.concat(ar || from);
47+
return to.concat(ar || Array.prototype.slice.call(from));
4848
};
4949
// error
5050
fs2.apply(void 0, __spreadArray(['a'], s2, false)); // error on ...s2

tests/baselines/reference/callWithSpread5.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1616
ar[i] = from[i];
1717
}
1818
}
19-
return to.concat(ar || from);
19+
return to.concat(ar || Array.prototype.slice.call(from));
2020
};
2121
fn.apply(void 0, __spreadArray(__spreadArray([], nnnu, false), [x], false));
2222
fn.apply(void 0, __spreadArray(__spreadArray([], nntnnnt, false), [x], false));

tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7777
ar[i] = from[i];
7878
}
7979
}
80-
return to.concat(ar || from);
80+
return to.concat(ar || Array.prototype.slice.call(from));
8181
};
8282
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
8383
// An expression of type S is considered assignable to an assignment target V if one of the following is true

tests/baselines/reference/destructuringArrayBindingPatternAndAssignment1ES5iterable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9393
ar[i] = from[i];
9494
}
9595
}
96-
return to.concat(ar || from);
96+
return to.concat(ar || Array.prototype.slice.call(from));
9797
};
9898
// In a destructuring assignment expression, the type of the expression on the right must be assignable to the assignment target on the left.
9999
// An expression of type S is considered assignable to an assignment target V if one of the following is true

tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4242
ar[i] = from[i];
4343
}
4444
}
45-
return to.concat(ar || from);
45+
return to.concat(ar || Array.prototype.slice.call(from));
4646
};
4747
// 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,
4848
// S is the type Any, or

tests/baselines/reference/destructuringParameterDeclaration3ES5iterable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7171
ar[i] = from[i];
7272
}
7373
}
74-
return to.concat(ar || from);
74+
return to.concat(ar || Array.prototype.slice.call(from));
7575
};
7676
function a1() {
7777
var x = [];

tests/baselines/reference/destructuringVariableDeclaration1ES5.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4949
ar[i] = from[i];
5050
}
5151
}
52-
return to.concat(ar || from);
52+
return to.concat(ar || Array.prototype.slice.call(from));
5353
};
5454
// The type T associated with a destructuring variable declaration is determined as follows:
5555
// If the declaration includes a type annotation, T is that type.

tests/baselines/reference/destructuringVariableDeclaration1ES5iterable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
6565
ar[i] = from[i];
6666
}
6767
}
68-
return to.concat(ar || from);
68+
return to.concat(ar || Array.prototype.slice.call(from));
6969
};
7070
// The type T associated with a destructuring variable declaration is determined as follows:
7171
// If the declaration includes a type annotation, T is that type.

tests/baselines/reference/excessiveStackDepthFlatArray.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4848
ar[i] = from[i];
4949
}
5050
}
51-
return to.concat(ar || from);
51+
return to.concat(ar || Array.prototype.slice.call(from));
5252
};
5353
configureStore({
5454
middleware: __spreadArray([], defaultMiddleware, true)

tests/baselines/reference/excessivelyLargeTupleSpread.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
4848
ar[i] = from[i];
4949
}
5050
}
51-
return to.concat(ar || from);
51+
return to.concat(ar || Array.prototype.slice.call(from));
5252
};
5353
var a0 = [0];
5454
var a1 = __spreadArray(__spreadArray([], a0, true), a0, true);

tests/baselines/reference/functionParameterArityMismatch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2424
ar[i] = from[i];
2525
}
2626
}
27-
return to.concat(ar || from);
27+
return to.concat(ar || Array.prototype.slice.call(from));
2828
};
2929
f1();
3030
f1(1, 2);

tests/baselines/reference/genericRestParameters1.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
174174
ar[i] = from[i];
175175
}
176176
}
177-
return to.concat(ar || from);
177+
return to.concat(ar || Array.prototype.slice.call(from));
178178
};
179179
f1 = f2;
180180
f2 = f1;

tests/baselines/reference/genericRestParameters2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8888
ar[i] = from[i];
8989
}
9090
}
91-
return to.concat(ar || from);
91+
return to.concat(ar || Array.prototype.slice.call(from));
9292
};
9393
f10(42, "hello");
9494
f10(42, "hello", true);

tests/baselines/reference/genericRestParameters3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7575
ar[i] = from[i];
7676
}
7777
}
78-
return to.concat(ar || from);
78+
return to.concat(ar || Array.prototype.slice.call(from));
7979
};
8080
f1("foo", "abc");
8181
f1("foo", 10, true);

tests/baselines/reference/keyofAndIndexedAccess.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
681681
ar[i] = from[i];
682682
}
683683
}
684-
return to.concat(ar || from);
684+
return to.concat(ar || Array.prototype.slice.call(from));
685685
};
686686
var Shape = /** @class */ (function () {
687687
function Shape() {

tests/baselines/reference/literalFreshnessPropagationOnNarrowing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
6969
ar[i] = from[i];
7070
}
7171
}
72-
return to.concat(ar || from);
72+
return to.concat(ar || Array.prototype.slice.call(from));
7373
};
7474
function f1() {
7575
var b = true;

tests/baselines/reference/newWithSpread.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
104104
ar[i] = from[i];
105105
}
106106
}
107-
return to.concat(ar || from);
107+
return to.concat(ar || Array.prototype.slice.call(from));
108108
};
109109
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
110110
function f(x, y) {

tests/baselines/reference/newWithSpreadES5.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
103103
ar[i] = from[i];
104104
}
105105
}
106-
return to.concat(ar || from);
106+
return to.concat(ar || Array.prototype.slice.call(from));
107107
};
108108
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
109109
function f(x, y) {

tests/baselines/reference/noCrashOnNoLib.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1515
ar[i] = from[i];
1616
}
1717
}
18-
return to.concat(ar || from);
18+
return to.concat(ar || Array.prototype.slice.call(from));
1919
};
2020
exports.__esModule = true;
2121
exports.f = void 0;

tests/baselines/reference/operationsAvailableOnPromisedType.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8080
ar[i] = from[i];
8181
}
8282
}
83-
return to.concat(ar || from);
83+
return to.concat(ar || Array.prototype.slice.call(from));
8484
};
8585
function fn(a, b, c, d, e, f, g) {
8686
var c_1, c_1_1;

tests/baselines/reference/readonlyRestParameters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3636
ar[i] = from[i];
3737
}
3838
}
39-
return to.concat(ar || from);
39+
return to.concat(ar || Array.prototype.slice.call(from));
4040
};
4141
function f0(a, b) {
4242
f0(a, b);

tests/baselines/reference/recursiveReverseMappedType.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2424
ar[i] = from[i];
2525
}
2626
}
27-
return to.concat(ar || from);
27+
return to.concat(ar || Array.prototype.slice.call(from));
2828
};
2929
function join(l) {
3030
return __spreadArray(['marker'], l, true);

tests/baselines/reference/recursiveTypeReferences1.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
139139
ar[i] = from[i];
140140
}
141141
}
142-
return to.concat(ar || from);
142+
return to.concat(ar || Array.prototype.slice.call(from));
143143
};
144144
var a0 = 1;
145145
var a1 = [1, [2, 3], [4, [5, [6, 7]]]];

tests/baselines/reference/restTuplesFromContextualTypes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
108108
ar[i] = from[i];
109109
}
110110
}
111-
return to.concat(ar || from);
111+
return to.concat(ar || Array.prototype.slice.call(from));
112112
};
113113
(function (a, b, c) { }).apply(void 0, t1);
114114
(function () {

tests/baselines/reference/selfReferencingSpreadInLoop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1313
ar[i] = from[i];
1414
}
1515
}
16-
return to.concat(ar || from);
16+
return to.concat(ar || Array.prototype.slice.call(from));
1717
};
1818
var additional = [];
1919
for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {

tests/baselines/reference/spliceTuples.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3232
ar[i] = from[i];
3333
}
3434
}
35-
return to.concat(ar || from);
35+
return to.concat(ar || Array.prototype.slice.call(from));
3636
};
3737
var k1;
3838
k1 = __spreadArray([1], sb, true);

tests/baselines/reference/spreadBooleanRespectsFreshness.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1515
ar[i] = from[i];
1616
}
1717
}
18-
return to.concat(ar || from);
18+
return to.concat(ar || Array.prototype.slice.call(from));
1919
};
2020
foo1 = __spreadArray([], Array.isArray(foo2) ? foo2 : [foo2], true);

0 commit comments

Comments
 (0)