(
this: Parser,
left: N.Expression | N.PrivateName,
leftStartLoc: Position,
minPrec: number,
)
| 492 | // operator that has a lower precedence than the set it is parsing. |
| 493 | |
| 494 | parseExprOp( |
| 495 | this: Parser, |
| 496 | left: N.Expression | N.PrivateName, |
| 497 | leftStartLoc: Position, |
| 498 | minPrec: number, |
| 499 | ): N.Expression { |
| 500 | const op = this.state.type; |
| 501 | const isOperator = this.isBinaryOperator(op); |
| 502 | |
| 503 | if (this.isPrivateName(left)) { |
| 504 | // https://tc39.es/ecma262/#prod-RelationalExpression |
| 505 | // RelationalExpression [In, Yield, Await] |
| 506 | // [+In] PrivateIdentifier in ShiftExpression[?Yield, ?Await] |
| 507 | |
| 508 | const value = this.getPrivateNameSV(left); |
| 509 | |
| 510 | if ( |
| 511 | minPrec >= tokenOperatorPrecedence(tt._in) || |
| 512 | op !== tt._in || |
| 513 | !isOperator |
| 514 | ) { |
| 515 | this.raise(Errors.PrivateInExpectedIn, leftStartLoc, { |
| 516 | identifierName: value, |
| 517 | }); |
| 518 | } |
| 519 | |
| 520 | this.classScope.usePrivateName(value, leftStartLoc); |
| 521 | } |
| 522 | |
| 523 | if (isOperator) { |
| 524 | let prec = tokenOperatorPrecedence(op); |
| 525 | if (prec > minPrec) { |
| 526 | if (op === tt.pipeline) { |
| 527 | this.expectPlugin("pipelineOperator"); |
| 528 | if (this.prodParam.inFSharpPipelineDirectBody) { |
| 529 | // Within the F#-style pipeline body, parseExprOps calls parseExprOp |
| 530 | // with minPrec = 0, such that any |> directly within a ConciseBody |
| 531 | // marks the end of the arrow function. We check here instead of |
| 532 | // parseExprOps so that the check doesn't have to be invoked if |
| 533 | // pipeline operators are not used at all. |
| 534 | |
| 535 | // PrivateName must be followed by `in`, but we have `|>` |
| 536 | return left as N.Expression; |
| 537 | } |
| 538 | } |
| 539 | const node = this.startNodeAt<N.LogicalExpression | N.BinaryExpression>( |
| 540 | leftStartLoc, |
| 541 | ); |
| 542 | node.left = left; |
| 543 | node.operator = this.state.value; |
| 544 | |
| 545 | const logical = op === tt.logicalOR || op === tt.logicalAND; |
| 546 | const coalesce = op === tt.nullishCoalescing; |
| 547 | |
| 548 | if (coalesce) { |
| 549 | // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions. |
| 550 | // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error. |
| 551 | prec = tokenOperatorPrecedence(tt.logicalAND); |
nothing calls this directly
no test coverage detected