Closed
Description
This problem exists for Version 2.3.4
at least through Version 2.6.1
I have this TS code (verbatim, as it should be):
source(...args: string[]): DefineObjectContext {
this.opts.sourced = this.opts.sourced || {};
Array.from(arguments).forEach(a => {
if (Array.isArray(a)) {
// break into any arrays, recursively
this.source(...a);
}
else if (typeof a === 'string') {
this.opts.sourced[a] = true;
}
else {
throw new Error('argument must be a string or an array of strings.');
}
});
return this;
}
It gets transpiled to:
DefineObjectContext.prototype.source = function () {
var _this = this;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
this.opts.sourced = this.opts.sourced || {};
Array.from(arguments).forEach(function (a) {
if (Array.isArray(a)) {
_this.source.apply(_this, a);
}
else if (typeof a === 'string') {
_this.opts.sourced[a] = true;
}
else {
throw new Error('argument must be a string or an array of strings.');
}
});
return this;
};
Expected behavior:
I wouldn't expect the need for arguments to be decomposed into the variable called args, since args is not being used!
Actual behavior:
The args variable is generated, for no reason.