microbundle
microbundle copied to clipboard
[Transpiling] Rest parameters with async bug
Minimal test case:
export const brokenArgsRest = async (...props) => {
await someAsyncFunction(async () => {
console.log(props)
})
}
export const someAsyncFunction = async callback => {
await callback()
}
generates
var brokenArgsRest = function brokenArgsRest() {
return Promise.resolve(someAsyncFunction(function () {
try {
var _arguments2 = arguments;
console.log([].slice.call(_arguments2));
return Promise.resolve();
} catch (e) {
return Promise.reject(e);
}
})).then(function () {});
};
var someAsyncFunction = function someAsyncFunction(callback) {
try {
return Promise.resolve(callback()).then(function () {});
} catch (e) {
return Promise.reject(e);
}
};
var _arguments2 = arguments; should be one more level up
Context: We hit this bug on fcl-js lib : https://github.com/onflow/flow-js-testing/issues/182
PS: my js knowledge is limited, but seems related to inlining somehow.