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

Function parseHackPipeBody

packages/babel-parser/src/parser/expression.ts:628–648  ·  view source on GitHub ↗
(this: Parser)

Source from the content-addressed store, hash-verified

626 }
627
628 parseHackPipeBody(this: Parser): N.Expression {
629 const { startLoc } = this.state;
630 const body = this.parseMaybeAssign();
631 const requiredParentheses = UnparenthesizedPipeBodyDescriptions.has(
632 // @ts-expect-error TS2345: Argument of type 'string' is not assignable to parameter of type '"ArrowFunctionExpression" | "YieldExpression" | "AssignmentExpression" | "ConditionalExpression"'.
633 body.type,
634 );
635
636 // TODO: Check how to handle type casts in Flow and TS once they are supported
637 if (requiredParentheses && !body.extra?.parenthesized) {
638 this.raise(Errors.PipeUnparenthesizedBody, startLoc, {
639 type: body.type as UnparenthesizedPipeBodyTypes,
640 });
641 }
642 if (!this.topicReferenceWasUsedInCurrentContext()) {
643 // A Hack pipe body must use the topic reference at least once.
644 this.raise(Errors.PipeTopicUnused, startLoc);
645 }
646
647 return body;
648 }
649
650 checkExponentialAfterUnary(
651 node: N.AwaitExpression | Undone<N.UnaryExpression>,

Callers

nothing calls this directly

Calls 2

parseMaybeAssignMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected