MCPcopy Create free account
hub / github.com/babel/babel / parseAwait

Function parseAwait

packages/babel-parser/src/parser/expression.ts:2971–3005  ·  view source on GitHub ↗
(
    this: Parser,
    startLoc: Position,
    soloAwait?: boolean,
  )

Source from the content-addressed store, hash-verified

2969 // Parses await expression inside async function.
2970
2971 parseAwait(
2972 this: Parser,
2973 startLoc: Position,
2974 soloAwait?: boolean,
2975 ): N.AwaitExpression {
2976 const startIndex = startLoc.index;
2977 const node = this.startNodeAt<N.AwaitExpression>(startLoc);
2978
2979 this.expressionScope.recordParameterInitializerError(
2980 Errors.AwaitExpressionFormalParameter,
2981 startIndex,
2982 );
2983
2984 if (this.eat(tt.star)) {
2985 this.raise(Errors.ObsoleteAwaitStar, startLoc);
2986 }
2987
2988 if (
2989 !this.scope.inFunction &&
2990 !(this.optionFlags & OptionFlags.AllowAwaitOutsideFunction)
2991 ) {
2992 if (this.isAmbiguousPrefixOrIdentifier()) {
2993 this.ambiguousScriptDifferentAst = true;
2994 } else {
2995 this.sawUnambiguousESM = true;
2996 }
2997 }
2998
2999 if (!soloAwait) {
3000 this.state.canStartArrow = false;
3001 node.argument = this.parseMaybeUnary(null, true);
3002 }
3003
3004 return this.finishNode(node, "AwaitExpression");
3005 }
3006
3007 isAmbiguousPrefixOrIdentifier(): boolean {
3008 if (this.hasPrecedingLineBreak()) return true;

Callers

nothing calls this directly

Calls 3

parseMaybeUnaryMethod · 0.80
finishNodeMethod · 0.80

Tested by

no test coverage detected