skip flow types when finding rest parameter references

This commit is contained in:
Sebastian McKenzie 2015-06-26 23:29:09 +01:00
parent 50ca6b1018
commit 54819b94e9
3 changed files with 26 additions and 0 deletions

View File

@ -9,6 +9,11 @@ var memberExpressionOptimisationVisitor = {
} }
}, },
Flow() {
// don't touch reference in type annotations
this.skip();
},
Function(node, parent, scope, state) { Function(node, parent, scope, state) {
// skip over functions as whatever `arguments` we reference inside will refer // skip over functions as whatever `arguments` we reference inside will refer
// to the wrong function // to the wrong function

View File

@ -0,0 +1,9 @@
function foo(
x: Object,
...types
): { types: Array<number>, x: Object } {
return {
types: types,
x: x,
};
}

View File

@ -0,0 +1,12 @@
"use strict";
function foo(x) {
for (var _len = arguments.length, types = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
types[_key - 1] = arguments[_key];
}
return {
types: types,
x: x
};
}