|
|
@ -7,7 +7,17 @@ import * as b from '../../../../utils/builders.js';
|
|
|
|
* @param {Context} context
|
|
|
|
* @param {Context} context
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function AwaitExpression(node, context) {
|
|
|
|
export function AwaitExpression(node, context) {
|
|
|
|
if (context.state.scope.function_depth > 1) {
|
|
|
|
// if `await` is inside a function, or inside `<script module>`,
|
|
|
|
|
|
|
|
// allow it, otherwise error
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
context.state.scope.function_depth === 0 ||
|
|
|
|
|
|
|
|
context.path.some(
|
|
|
|
|
|
|
|
(node) =>
|
|
|
|
|
|
|
|
node.type === 'ArrowFunctionExpression' ||
|
|
|
|
|
|
|
|
node.type === 'FunctionDeclaration' ||
|
|
|
|
|
|
|
|
node.type === 'FunctionExpression'
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
) {
|
|
|
|
return context.next();
|
|
|
|
return context.next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|