This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
π Confusing error for await-expression inside non-async context #2479
Labels
A-Parser
Area: parser
L-JavaScript
Langauge: JavaScript
S-Bug: confirmed
Status: report has been confirmed as a valid bug
What happened?
In non-async context (Module),
await expression shows
which is super confusing, and the formatter will break it into two lines.
Expected result
acorn:
Cannot use keyword 'await' outside an async function
babel:
Unexpected reserved word 'await'.
swc:
await isn't allowed in non-async function
typescript:
'await' expressions are only allowed within async functions and at the top levels of modules.
Playground
https://play.rome.tools/?lineWidth=80&indentStyle=tab"eStyle=double&indentWidth=2&typescript=false&jsx=false&sourceType=module#ZgB1AG4AYwB0AGkAbwBuACAAZgBvAG8AKAApACAAewAKACAAIABhAHcAYQBpAHQAIABiAGEAcgA7AAoAfQA=
Code of Conduct
The text was updated successfully, but these errors were encountered: