Parse for await (async of ...) (#13244)
This commit is contained in:
@@ -283,8 +283,13 @@ export function LogicalExpression(node: any, parent: any): boolean {
|
||||
|
||||
export function Identifier(node: t.Identifier, parent: t.Node): boolean {
|
||||
// ECMAScript specifically forbids a for-of loop from starting with the
|
||||
// token sequence "for ( async of", because it would be ambiguous with
|
||||
// "for (async of => {};;)", so we need to add extra parentheses.
|
||||
// token sequence `for (async of`, because it would be ambiguous with
|
||||
// `for (async of => {};;)`, so we need to add extra parentheses.
|
||||
//
|
||||
// If the parent is a for-await-of loop (i.e. parent.await === true), the
|
||||
// parentheses aren't strictly needed, but we add them anyway because
|
||||
// some tools (including earlier Babel versions) can't parse
|
||||
// `for await (async of [])` without them.
|
||||
return (
|
||||
node.name === "async" && t.isForOfStatement(parent) && node === parent.left
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user