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

Function parseExprListItem

packages/babel-parser/src/parser/expression.ts:2779–2824  ·  view source on GitHub ↗
(
    this: Parser,
    close: TokenType,
    allowEmpty?: boolean | null,
    refExpressionErrors?: ExpressionErrors | null,
    allowPlaceholder?: boolean | null,
  )

Source from the content-addressed store, hash-verified

2777 allowPlaceholder?: boolean | null,
2778 ): N.Expression;
2779 parseExprListItem(
2780 this: Parser,
2781 close: TokenType,
2782 allowEmpty?: boolean | null,
2783 refExpressionErrors?: ExpressionErrors | null,
2784 allowPlaceholder?: boolean | null,
2785 ):
2786 | N.Expression
2787 | N.SpreadElement
2788 | N.ArgumentPlaceholder
2789 | N.VoidPattern
2790 | N.AssignmentPattern
2791 | N.TSTypeCastExpression
2792 | null {
2793 let elt;
2794 if (this.match(tt.comma)) {
2795 if (!allowEmpty) {
2796 this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
2797 unexpected: ",",
2798 });
2799 }
2800 elt = null;
2801 } else if (this.match(tt.ellipsis)) {
2802 const spreadNodeStartLoc = this.state.startLoc;
2803
2804 elt = this.parseParenItem(
2805 this.parseSpread(refExpressionErrors),
2806 spreadNodeStartLoc,
2807 );
2808 } else if (this.match(tt.question)) {
2809 this.expectPlugin("partialApplication");
2810 if (!allowPlaceholder) {
2811 this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
2812 }
2813 const node = this.startNode<N.ArgumentPlaceholder>();
2814 this.next();
2815 elt = this.finishNode(node, "ArgumentPlaceholder");
2816 } else {
2817 elt = this.parseMaybeAssignAllowInOrVoidPattern(
2818 close,
2819 refExpressionErrors,
2820 true,
2821 );
2822 }
2823 return elt;
2824 }
2825
2826 // Parse the next token as an identifier. If `liberal` is true (used
2827 // when parsing properties), it will also convert keywords into

Callers

nothing calls this directly

Calls 5

matchMethod · 0.80
curPositionMethod · 0.80
nextMethod · 0.80
finishNodeMethod · 0.80
parseParenItemMethod · 0.45

Tested by

no test coverage detected