Detect use of `Array.prototype.slice` in `arg-rest` transform #191

Open
nene opened this Issue Oct 15, 2016 · 1 comment

Projects

None yet

1 participant

@nene
Collaborator
nene commented Oct 15, 2016

Currently this code:

function foo() {
  var items = Array.prototype.slice.call(arguments);
  console.log(items);
}

will be transformed to:

function foo(...args) {
  var items = Array.prototype.slice.call(args);
  console.log(items);
}

but we'd really like to get this:

function foo(...items) {
  console.log(items);
}

Similar thing with other helpers like _.toArray(arguments) or Array.from(arguments).

@nene
Collaborator
nene commented Oct 15, 2016

Similarly we currently don't transform the following at all:

function foo(a, b) {
    var rest = Array.prototype.slice.call(arguments, 2);
    console.log(a, b, rest);
}

we'd really like to transform the above to:

function foo(a, b, ...rest) {
    console.log(a, b, rest);
}
@nene nene added the enhancement label Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment