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

Function parseExprListItem

packages/babel-parser/src/parser/expression.ts:2787–2832  ·  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

2785 allowPlaceholder?: boolean | null,
2786 ): N.Expression;
2787 parseExprListItem(
2788 this: Parser,
2789 close: TokenType,
2790 allowEmpty?: boolean | null,
2791 refExpressionErrors?: ExpressionErrors | null,
2792 allowPlaceholder?: boolean | null,
2793 ):
2794 | N.Expression
2795 | N.SpreadElement
2796 | N.ArgumentPlaceholder
2797 | N.VoidPattern
2798 | N.AssignmentPattern
2799 | N.TSTypeCastExpression
2800 | null {
2801 let elt;
2802 if (this.match(tt.comma)) {
2803 if (!allowEmpty) {
2804 this.raise(Errors.UnexpectedToken, this.state.curPosition(), {
2805 unexpected: ",",
2806 });
2807 }
2808 elt = null;
2809 } else if (this.match(tt.ellipsis)) {
2810 const spreadNodeStartLoc = this.state.startLoc;
2811
2812 elt = this.parseParenItem(
2813 this.parseSpread(refExpressionErrors),
2814 spreadNodeStartLoc,
2815 );
2816 } else if (this.match(tt.question)) {
2817 this.expectPlugin("partialApplication");
2818 if (!allowPlaceholder) {
2819 this.raise(Errors.UnexpectedArgumentPlaceholder, this.state.startLoc);
2820 }
2821 const node = this.startNode<N.ArgumentPlaceholder>();
2822 this.next();
2823 elt = this.finishNode(node, "ArgumentPlaceholder");
2824 } else {
2825 elt = this.parseMaybeAssignAllowInOrVoidPattern(
2826 close,
2827 refExpressionErrors,
2828 true,
2829 );
2830 }
2831 return elt;
2832 }
2833
2834 // Parse the next token as an identifier. If `liberal` is true (used
2835 // 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