Skip to content

Commit

Permalink
refactor: simplify isAwaitAllowed (#12398)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Nov 25, 2020
1 parent 645fe63 commit 89f3247
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -2343,10 +2343,9 @@ export default class ExpressionParser extends LValParser {
}

isAwaitAllowed(): boolean {
if (this.scope.inFunction) return this.prodParam.hasAwait;
if (this.options.allowAwaitOutsideFunction) return true;
if (this.hasPlugin("topLevelAwait")) {
return this.inModule && this.prodParam.hasAwait;
if (this.prodParam.hasAwait) return true;
if (this.options.allowAwaitOutsideFunction && !this.scope.inFunction) {
return true;
}
return false;
}
Expand Down

0 comments on commit 89f3247

Please sign in to comment.