refactor: simplify isAwaitAllowed (#12398)

This commit is contained in:
Huáng Jùnliàng
2020-11-25 13:49:35 -05:00
committed by GitHub
parent 645fe637f2
commit 89f3247e32

View File

@@ -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;
}