Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,20 +862,34 @@ function lowerStatement(
);
return;
}
case 'VariableDeclaration': {
const stmt = stmtPath as NodePath<t.VariableDeclaration>;
const nodeKind: t.VariableDeclaration['kind'] = stmt.node.kind;
if (nodeKind === 'var') {
builder.errors.push({
reason: `(BuildHIR::lowerStatement) Handle ${nodeKind} kinds in VariableDeclaration`,
category: ErrorCategory.Todo,
loc: stmt.node.loc ?? null,
suggestions: null,
});
return;
}
case 'VariableDeclaration': {
const stmt = stmtPath as NodePath<t.VariableDeclaration>;
const nodeKind: t.VariableDeclaration['kind'] = stmt.node.kind;
if (nodeKind === 'var') {
builder.errors.push({
reason: `(BuildHIR::lowerStatement) Handle ${nodeKind} kinds in VariableDeclaration`,
category: ErrorCategory.Todo,
loc: stmt.node.loc ?? null,
suggestions: null,
});
return;
}
// ADD THIS NEW CHECK FOR 'using' and 'await using'
if (nodeKind === 'using' || nodeKind === 'await using') {
builder.errors.push({
reason: `(BuildHIR::lowerStatement) 'using' declarations are not yet supported by React Compiler`,
category: ErrorCategory.Todo,
loc: stmt.node.loc ?? null,
suggestions: null,
});
return;
}
const kind =
nodeKind === 'let' ? InstructionKind.Let : InstructionKind.Const;
nodeKind === 'let'
? InstructionKind.Let
: nodeKind === 'using' || nodeKind === 'await using'
? InstructionKind.Let // Treat 'using' similar to 'let' for now
: InstructionKind.Const;
for (const declaration of stmt.get('declarations')) {
const id = declaration.get('id');
const init = declaration.get('init');
Expand Down