New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arguments undefined when spreading args in async arrow function (T7329) #4270
Comments
Still an issue. Minimal input: const modifyResolver = () => {
return async (...args) => {
//args;
y(...args);
};
}; Output:
( Seems related to #4219? |
It looks like the issue is only present once applying the "latest" preset. It works as expected with just the async to generator transpiler. See |
@gajus Ah, you're right! Good call! |
Closing this issue because it is a duplicate of #4219. Thank you for taking the time to report though 😬 |
Bug information
Options
Input code
Description
Basically, when I try to define a function like so:
The arguments are undefined. When you look at the output you can clearly see that
arguments
gets assigned outside of the function scope. I'm not sure why that happens. Removingasync
fixes the problem, using thefunction
keyword fixes the problem, and (my favourite), assigningargs
to a value (or otherwise accessing it) also fixes the problem.[[ https://babeljs.io/repl/#?evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-0&experimental=true&loose=false&spec=false&code=%2F%2F%20modified%20from%20kadirahq%2Fgraphql-errors%0A%0Aconst%20modifyResolver%20%3D%20(field%2C%20handler)%20%3D%3E%20%7B%0A%20%20%0A%20%20const%20originalResolve%20%3D%20field.resolve%3B%0A%20%20%0A%20%20field.resolve%20%3D%20async%20(...args)%20%3D%3E%20%7B%20%2F%2F%20Workaround%201%3A%20use%20%60async%20function(...args)%20%7B%60%0A%0A%20%20%20%20try%20%7B%0A%20%20%20%20%20%20%2F%2F%20const%20b%20%3D%20args%3B%20%2F%2F%20Workaround%202%3A%20Access%20args%20--%20even%20when%20unused.%0A%20%20%20%20%20%20const%20res%20%3D%20originalResolve(...args)%3B%20%2F%2F%20Problem%3A%20arguments%20is%20undefined%20here%0A%20%20%20%20%20%20return%20await%20Promise.resolve(res)%3B%0A%20%20%20%20%7D%0A%20%20%20%20catch%20(err)%20%7B%0A%20%20%20%20%20%20throw%20handler(err)%3B%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%7D%3B | REPL with sample code ]]
The text was updated successfully, but these errors were encountered: