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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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) {

0 commit comments

Comments
 (0)