google / google/closure-compiler
Simple Array Destructuring shouldn't require use of $jscomp
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
When using a very simple destructuring pattern, it should be possible to convert this to simple assignments. Reading the spec, http://www.ecma-international.org/ecma-262/6.0/#sec-destructuring-assignment, I can see why the definition of `$jscomp` is what it is, but it seems like overkill for simple assignments.
Given the input:
``` javascript
function add(a) {
let [b,c] = a;
return b+c;
}
add([1,2])
```
I would expect the output to be something along the lines of:
``` javascript
function test(a) {
var b = a[0], c = a[1];
return b+c;
}
test([1,2])
```
Instead, what I'm seeing is:
``` javascript
/* $jscomp definition */;
function add(a){
var b=$jscomp.makeIterator(a);
a=b.next().value;
b=b.next().value;
return a+b
}
add([1,2]);
```
Contributor guide
Assessment
This issue has not been assessed yet.