diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts index 826b720300839..e5a067018dac9 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts @@ -1668,6 +1668,15 @@ function lowerExpression( const left = lowerExpressionToTemporary(builder, leftPath); const right = lowerExpressionToTemporary(builder, expr.get("right")); const operator = expr.node.operator; + if (operator === "|>") { + builder.errors.push({ + reason: `(BuildHIR::lowerExpression) Pipe operator not supported`, + severity: ErrorSeverity.Todo, + loc: leftPath.node.loc ?? null, + suggestions: null, + }); + return { kind: "UnsupportedNode", node: exprNode, loc: exprLoc }; + } return { kind: "BinaryExpression", operator, @@ -1893,7 +1902,9 @@ function lowerExpression( ); } - const operators: { [key: string]: t.BinaryExpression["operator"] } = { + const operators: { + [key: string]: Exclude">; + } = { "+=": "+", "-=": "-", "/=": "/", @@ -2307,6 +2318,20 @@ function lowerExpression( }); return { kind: "UnsupportedNode", node: expr.node, loc: exprLoc }; } + } else if (expr.node.operator === "throw") { + builder.errors.push({ + reason: `Throw expressions are not supported`, + severity: ErrorSeverity.InvalidJS, + loc: expr.node.loc ?? null, + suggestions: [ + { + description: "Remove this line", + range: [expr.node.start!, expr.node.end!], + op: CompilerSuggestionOperation.Remove, + }, + ], + }); + return { kind: "UnsupportedNode", node: expr.node, loc: exprLoc }; } else { return { kind: "UnaryExpression", diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts index d544269869297..229433503448b 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts @@ -866,7 +866,7 @@ export type InstructionValue = | JSXText | { kind: "BinaryExpression"; - operator: t.BinaryExpression["operator"]; + operator: Exclude">; left: Place; right: Place; loc: SourceLocation; @@ -881,7 +881,7 @@ export type InstructionValue = | MethodCall | { kind: "UnaryExpression"; - operator: t.UnaryExpression["operator"]; + operator: Exclude; value: Place; loc: SourceLocation; }