-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
I had a function, which was being transpiled correctly, but now is not.
const deepAssign = (...args) => (args = [].concat(...args)).length === 0 ? undefined : Object.assign(...args);Essentially, I am assigning to the args variable but because I'm not passing the args variable anywhere, all references to it are being optimised to reference arguments directly.
The transpiled code contains a variable declartion for _ref2 but not for args:
var deepAssign = function() {
var _ref2;
return (args = (_ref2 = []).concat.apply(_ref2, arguments)).length === 0 ? undefined : _Object$assign.apply(Object, arguments);
};In fact, it's even using arguments in the last part of the ternary expression even though that's not referencing the flattened array as returned by concat.
Expected output would be something similar to:
var deepAssign = function() {
var args = arguments, _ref2;
return (args = (_ref2 = []).concat.apply(_ref2, args)).length === 0 ? undefined : _Object$assign.apply(Object, args);Although I don't know the extent of the repercussions, re compiler optimizations, the assignment of arguments to args will have. Should I just accept I can't do this in a one-liner and declare a different variable?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue