[compiler] Add fire to known React APIs (#31795)
Makes `fire` a known export for type-based analysis -- --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31795). * #31811 * #31798 * #31797 * #31796 * __->__ #31795 * #31794
Jordan Brown committed
Dec 16, 2024 at 15:48 UTC
c869063f0dd92f09244bb43e44fe175a5f97b7e6
2 files changed
+17
compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
+16
@@ -9,6 +9,7 @@ import {Effect, ValueKind, ValueReason} from './HIR';
9
import {
10
BUILTIN_SHAPES,
11
BuiltInArrayId,
12
+ BuiltInFireId,
13
BuiltInMixedReadonlyId,
14
BuiltInUseActionStateId,
15
BuiltInUseContextHookId,
@@ -468,6 +469,21 @@ const REACT_APIS: Array<[string, BuiltInType]> = [
469
BuiltInUseOperatorId,
470
),
471
],
472
+ [
473
+ 'fire',
474
+ addFunction(
475
+ DEFAULT_SHAPES,
476
+ [],
477
+ {
478
+ positionalParams: [],
479
+ restParam: null,
480
+ returnType: {kind: 'Primitive'},
481
+ calleeEffect: Effect.Read,
482
+ returnValueKind: ValueKind.Frozen,
483
+ },
484
+ BuiltInFireId,
485
+ ),
486
+ ],
487
];
488
489
TYPED_GLOBALS.push(
compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
+1
@@ -213,6 +213,7 @@ export const BuiltInDispatchId = 'BuiltInDispatch';
213
export const BuiltInUseContextHookId = 'BuiltInUseContextHook';
214
export const BuiltInUseTransitionId = 'BuiltInUseTransition';
215
export const BuiltInStartTransitionId = 'BuiltInStartTransition';
216
+export const BuiltInFireId = 'BuiltInFire';
217
218
// ShapeRegistry with default definitions for built-ins.
219
export const BUILTIN_SHAPES: ShapeRegistry = new Map();