Adding a comment to an async function before the first argument can result in a syntax error #11830
Labels
Has PR
i: bug
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
pkg: generator
Bug Report
Current behavior
If you place a comment before the first (and only) argument of an async function (but after the async keyword), and the function has only a single argument, and if you use the await keyword inside that function, the compiled javascript won't run because the function isn't marked as async.
You get the following error when you run the compiled code:
Here's a full reproduction
Input Code
Expected behavior
The compiled code should run without error. Presumably by making sure the async keyword is always on the same line as the function declaration
Babel Configuration (.babelrc)
The default config will generate the error (as of the day I posted this), also the following config will generate the error (note the borwserlist config is necessary to generate the error, otherwise regeneratorRuntime is used instead of emitting the async/await keywords):
.babelrc
package.json
Environment
Possible Solution
I assume that always wrapping the arguments of an async function in parenthesis (and keeping the async keyword on the same line as the opening parentheses) would fix the issue.
The text was updated successfully, but these errors were encountered: