Argument spread transpilation is incorrect in arrow functions
When transpiling to a target with arrow functions but without argument spread (i.e. Node 4), the following code is generated:
original:
const v = (...args) => myFunc(instance, ...args);
transpiled:
const v = () => { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; return myFunc.apply(void 0, [ instance ].concat( args )); };
This is incorrect: Arrow functions do not have their own arguments object. https://tc39.github.io/ecma262/#sec-functiondeclarationinstantiation
If func.ThisMode is lexical, then NOTE Arrow functions never have an arguments objects. Let argumentsObjectNeeded be false.
The arguments object is populated from the enclosing scope, and the results are unexpected.