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

Function parseConditional

packages/babel-parser/src/parser/expression.ts:426–442  ·  view source on GitHub ↗
(
    this: Parser,
    expr: N.Expression,
    startLoc: Position,
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    refExpressionErrors?: ExpressionErrors | null,
  )

Source from the content-addressed store, hash-verified

424 }
425
426 parseConditional(
427 this: Parser,
428 expr: N.Expression,
429 startLoc: Position,
430 // eslint-disable-next-line @typescript-eslint/no-unused-vars
431 refExpressionErrors?: ExpressionErrors | null,
432 ): N.Expression {
433 if (this.eat(tt.question)) {
434 const node = this.startNodeAt<N.ConditionalExpression>(startLoc);
435 node.test = expr;
436 node.consequent = this.parseMaybeAssignAllowIn();
437 this.expect(tt.colon);
438 node.alternate = this.parseMaybeAssign();
439 return this.finishNode(node, "ConditionalExpression");
440 }
441 return expr;
442 }
443
444 parseMaybeUnaryOrPrivate(
445 this: Parser,

Callers

nothing calls this directly

Calls 2

finishNodeMethod · 0.80
parseMaybeAssignMethod · 0.45

Tested by

no test coverage detected