(
this: Parser,
refExpressionErrors?: ExpressionErrors | null,
sawUnary?: boolean,
)
| 658 | // Parse unary operators, both prefix and postfix. |
| 659 | // https://tc39.es/ecma262/#prod-UnaryExpression |
| 660 | parseMaybeUnary( |
| 661 | this: Parser, |
| 662 | refExpressionErrors?: ExpressionErrors | null, |
| 663 | sawUnary?: boolean, |
| 664 | ): N.Expression { |
| 665 | const startLoc = this.state.startLoc; |
| 666 | const isAwait = this.isContextual(tt._await); |
| 667 | |
| 668 | if (isAwait && this.recordAwaitIfAllowed()) { |
| 669 | this.next(); |
| 670 | const expr = this.parseAwait(startLoc); |
| 671 | if (!sawUnary) this.checkExponentialAfterUnary(expr); |
| 672 | return expr; |
| 673 | } |
| 674 | if (tokenIsPrefix(this.state.type)) { |
| 675 | const update = this.match(tt.incDec); |
| 676 | const node = this.startNode<N.UnaryExpression | N.UpdateExpression>(); |
| 677 | node.operator = this.state.value; |
| 678 | node.prefix = true; |
| 679 | this.state.canStartArrow = false; |
| 680 | |
| 681 | if (this.match(tt._throw)) { |
| 682 | this.expectPlugin("throwExpressions"); |
| 683 | } |
| 684 | const isDelete = this.match(tt._delete); |
| 685 | this.next(); |
| 686 | |
| 687 | node.argument = this.parseMaybeUnary(null, true); |
| 688 | |
| 689 | this.checkExpressionErrors(refExpressionErrors, true); |
| 690 | |
| 691 | if (this.state.strict && isDelete) { |
| 692 | const arg = unwrapParenthesizedExpression(node.argument); |
| 693 | |
| 694 | if (arg.type === "Identifier") { |
| 695 | this.raise(Errors.StrictDelete, node); |
| 696 | } else if (this.hasPropertyAsPrivateName(arg)) { |
| 697 | this.raise(Errors.DeletePrivateField, node); |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | if (!update) { |
| 702 | if (!sawUnary) { |
| 703 | this.checkExponentialAfterUnary(node as Undone<N.UnaryExpression>); |
| 704 | } |
| 705 | return this.finishNode(node, "UnaryExpression"); |
| 706 | } |
| 707 | |
| 708 | const result = this.finishNode( |
| 709 | node as Undone<N.UpdateExpression>, |
| 710 | "UpdateExpression", |
| 711 | ); |
| 712 | this.checkLVal(result.argument, result); |
| 713 | return result; |
| 714 | } |
| 715 | |
| 716 | const expr = this.parseUpdate(refExpressionErrors); |
| 717 |
nothing calls this directly
no test coverage detected