Skip to content

Commit

Permalink
[compiler] Simplify FunctionExpression node
Browse files Browse the repository at this point in the history
Rather than storing the entire babel node, store only the required
information which is the node type.

This will be useful for when we synthesize new functions that don't have
a corresponding babel node.

ghstack-source-id: 9098cbdbc4b1e9a6e7dafa2e7645f6f4854e1eac
Pull Request resolved: #30544
  • Loading branch information
gsathya committed Aug 2, 2024
1 parent 1db4d6c commit a5a5816
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3270,7 +3270,7 @@ function lowerFunctionToValue(
return {
kind: 'FunctionExpression',
name,
expr: expr.node,
type: expr.node.type,
loc: exprLoc,
loweredFunc,
};
Expand Down
8 changes: 4 additions & 4 deletions compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1076,10 +1076,10 @@ export type FunctionExpression = {
kind: 'FunctionExpression';
name: string | null;
loweredFunc: LoweredFunction;
expr:
| t.ArrowFunctionExpression
| t.FunctionExpression
| t.FunctionDeclaration;
type:
| 'ArrowFunctionExpression'
| 'FunctionExpression'
| 'FunctionDeclaration';
loc: SourceLocation;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ function codegenInstructionValue(
),
reactiveFunction,
).unwrap();
if (instrValue.expr.type === 'ArrowFunctionExpression') {
if (instrValue.type === 'ArrowFunctionExpression') {
let body: t.BlockStatement | t.Expression = fn.body;
if (body.body.length === 1 && loweredFunc.directives.length == 0) {
const stmt = body.body[0]!;
Expand Down

0 comments on commit a5a5816

Please sign in to comment.