TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Destructuring the arguments variable

Open tylergoodman opened this issue 11 years ago • 23 comments

Doesn't work because the IArguments interface isn't defined as an Array type. Is there a reason behind this?

Example:

function test () {
  var [a] = arguments; // Error: Type 'IArguments' is not an array type.
}

One solution is doing this:

function (...args) {
  var [ one, two, three ] = args;
}

tylergoodman avatar May 22 '15 08:05 tylergoodman

@tylergoodman no problem - if you'd be willing to open up a separate issue as a suggestion, we could discuss the possibility among the team.

DanielRosenwasser avatar Jun 03 '15 04:06 DanielRosenwasser

@tylergoodman If you open an issue for this, please mention the issue number here.

JsonFreeman avatar Jun 03 '15 18:06 JsonFreeman

#3389

tylergoodman avatar Jun 04 '15 20:06 tylergoodman