Skip to content

[compiler][fire] Fire syntax changes#78

Open
everettbu wants to merge 1 commit into
mainfrom
pr32504
Open

[compiler][fire] Fire syntax changes#78
everettbu wants to merge 1 commit into
mainfrom
pr32504

Conversation

@everettbu

@everettbu everettbu commented Dec 12, 2025

Copy link
Copy Markdown

Mirror of facebook/react#32504
Original author: jbrown215



Stack created with Sapling. Best reviewed with ReviewStack.

  • #32505
  • -> #32504

@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Dec 12, 2025
@greptile-apps

greptile-apps Bot commented Dec 12, 2025

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR changes the fire() syntax from fire(fn()) to fire(fn)(), transforming it from immediately calling within fire to a curried pattern.

Key changes:

  • The old syntax was fire(foo(props)) where the function call happened inside fire
  • The new syntax is fire(foo)(props) where fire returns a wrapped function that is then called
  • Updated transformation logic to handle the new two-step call pattern
  • Added ensureLinearConsumption() validation to enforce that fire() results must be immediately called and cannot be stored, passed as arguments, or used in other ways
  • Replaced #callExpressions tracking with #fireCallResultsToReplacedBindings to map fire call results to their replaced bindings
  • Updated all error messages to reflect the new syntax pattern
  • All 52 test files updated to match new syntax and expected error messages

The implementation correctly validates that fire calls are linearly consumed (only used as the callee of another call expression), preventing misuse patterns like const f = fire(foo) or bar(fire(foo)).

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured and comprehensive. The transformation logic properly handles the syntax change from fire(fn()) to fire(fn)(). The new ensureLinearConsumption validation adds important safety checks. All test fixtures and expected outputs are updated consistently across 52 files, demonstrating thorough testing coverage
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
compiler/packages/babel-plugin-react-compiler/src/Transform/TransformFire.ts 5/5 Changed fire() syntax from fire(fn()) to fire(fn)(). Added ensureLinearConsumption validation, replaced callExpressions map with fireCallResultsToReplacedBindings, updated error messages
compiler/packages/babel-plugin-react-compiler/src/tests/fixtures/compiler/transform-fire/basic.js 5/5 Updated test to use new fire(foo)(props) syntax instead of fire(foo(props))
compiler/packages/babel-plugin-react-compiler/src/tests/fixtures/compiler/transform-fire/error.invalid-not-call.js 5/5 Added comprehensive test cases for invalid fire() usage: as function argument, assignment, and expression statement

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

52 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants