Repository: facebook/react
File: compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts (TypeScript)

Code before:
      return {
        kind: "RegExpLiteral",
        pattern: expr.node.pattern,
        flags: expr.node.flags,
        loc: expr.node.loc ?? GeneratedSource,
      };
    }
    case "TSNonNullExpression": {
      let expr = exprPath as NodePath<t.TSNonNullExpression>;
      return lowerExpression(builder, expr.get("expression"));
    }
    case "MetaProperty": {
      let expr = exprPath as NodePath<t.MetaProperty>;
      return {
        kind: "MetaProperty",
        meta: expr.node.meta.name,
        property: expr.node.property.name,
        loc: expr.node.loc ?? GeneratedSource,
      };
    }
    default: {
      builder.errors.push({
        reason: `(BuildHIR::lowerExpression) Handle ${exprPath.type} expressions`,
        severity: ErrorSeverity.Todo,
        loc: exprPath.node.loc ?? null,
        suggestions: null,
      });
      return { kind: "UnsupportedNode", node: exprNode, loc: exprLoc };
    }
  }
}

function lowerOptionalMemberExpression(
  builder: HIRBuilder,
  expr: NodePath<t.OptionalMemberExpression>,
  parentAlternate: BlockId | null
): { object: Place; value: Place } {
  const optional = expr.node.optional;
  const loc = expr.node.loc ?? GeneratedSource;
  const place = buildTemporaryPlace(builder, loc);
  const continuationBlock = builder.reserve(builder.currentBlockKind());
  const consequent = builder.reserve("value");

  /*
   * block to evaluate if the callee is null/undefined, this sets the result of the call to undefined.
   * note that we only create an alternate when first entering an optional subtree of the ast: if this
   * is a child of an optional node, we use the alterate created by the parent.
   */
  const alternate =
    parentAlternate !== null
      ? parentAlternate

Review comment (suggestion):
i think what we can do is limit this to `import` meta properties for now, and throw a Todo error for other `meta` values.

Code after:
      return {
        kind: "RegExpLiteral",
        pattern: expr.node.pattern,
        flags: expr.node.flags,
        loc: expr.node.loc ?? GeneratedSource,
      };
    }
    case "TSNonNullExpression": {
      let expr = exprPath as NodePath<t.TSNonNullExpression>;
      return lowerExpression(builder, expr.get("expression"));
    }
    case "MetaProperty": {
      let expr = exprPath as NodePath<t.MetaProperty>;
      if (
        expr.node.meta.name === "import" &&
        expr.node.property.name === "meta"
      ) {
        return {
          kind: "MetaProperty",
          meta: expr.node.meta.name,
          property: expr.node.property.name,
          loc: expr.node.loc ?? GeneratedSource,
        };
      }

      builder.errors.push({
        reason: `(BuildHIR::lowerExpression) Handle MetaProperty expressions other than import.meta`,
        severity: ErrorSeverity.Todo,
        loc: exprPath.node.loc ?? null,
        suggestions: null,
      });
      return { kind: "UnsupportedNode", node: exprNode, loc: exprLoc };
    }
    default: {
      builder.errors.push({
        reason: `(BuildHIR::lowerExpression) Handle ${exprPath.type} expressions`,
        severity: ErrorSeverity.Todo,
        loc: exprPath.node.loc ?? null,
        suggestions: null,
      });
      return { kind: "UnsupportedNode", node: exprNode, loc: exprLoc };
    }
  }
}

function lowerOptionalMemberExpression(
  builder: HIRBuilder,
  expr: NodePath<t.OptionalMemberExpression>,
  parentAlternate: BlockId | null
): { object: Place; value: Place } {
  const optional = expr.node.optional;