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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2343,10 +2343,9 @@ export default class ExpressionParser extends LValParser {
} }
isAwaitAllowed(): boolean { isAwaitAllowed(): boolean {
if (this.scope.inFunction) return this.prodParam.hasAwait; if (this.prodParam.hasAwait) return true;
if (this.options.allowAwaitOutsideFunction) return true; if (this.options.allowAwaitOutsideFunction && !this.scope.inFunction) {
if (this.hasPlugin("topLevelAwait")) { return true;
return this.inModule && this.prodParam.hasAwait;
} }
return false; return false;
} }