Skip to content

Commit

Permalink
refactor: simplify isAwaitAllowed (babel#12398)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung authored and nicolo-ribaudo committed Dec 2, 2020
1 parent a66f89c commit 0c6e7b6
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 @@ -2339,10 +2339,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 0c6e7b6

Please sign in to comment.