import * as BabelCore from '@babel/core'; import { NodePath as NodePath$1 } from '@babel/core'; import * as t from '@babel/types'; import { z } from 'zod'; import { NodePath, Scope } from '@babel/traverse'; interface Result { map(fn: (val: T) => U): Result; mapErr(fn: (val: E) => F): Result; mapOr(fallback: U, fn: (val: T) => U): U; mapOrElse(fallback: () => U, fn: (val: T) => U): U; andThen(fn: (val: T) => Result): Result; and(res: Result): Result; or(res: Result): Result; orElse(fn: (val: E) => Result): Result; isOk(): this is OkImpl; isErr(): this is ErrImpl; expect(msg: string): T; expectErr(msg: string): E; unwrap(): T; unwrapOr(fallback: T): T; unwrapOrElse(fallback: (val: E) => T): T; unwrapErr(): E; } declare class OkImpl implements Result { #private; constructor(val: T); map(fn: (val: T) => U): Result; mapErr(_fn: (val: never) => F): Result; mapOr(_fallback: U, fn: (val: T) => U): U; mapOrElse(_fallback: () => U, fn: (val: T) => U): U; andThen(fn: (val: T) => Result): Result; and(res: Result): Result; or(_res: Result): Result; orElse(_fn: (val: never) => Result): Result; isOk(): this is OkImpl; isErr(): this is ErrImpl; expect(_msg: string): T; expectErr(msg: string): never; unwrap(): T; unwrapOr(_fallback: T): T; unwrapOrElse(_fallback: (val: never) => T): T; unwrapErr(): never; } declare class ErrImpl implements Result { #private; constructor(val: E); map(_fn: (val: never) => U): Result; mapErr(fn: (val: E) => F): Result; mapOr(fallback: U, _fn: (val: never) => U): U; mapOrElse(fallback: () => U, _fn: (val: never) => U): U; andThen(_fn: (val: never) => Result): Result; and(_res: Result): Result; or(res: Result): Result; orElse(fn: (val: E) => ErrImpl): Result; isOk(): this is OkImpl; isErr(): this is ErrImpl; expect(msg: string): never; expectErr(_msg: string): E; unwrap(): never; unwrapOr(fallback: T): T; unwrapOrElse(fallback: (val: E) => T): T; unwrapErr(): E; } type AliasingEffect = { kind: 'Freeze'; value: Place; reason: ValueReason; } | { kind: 'Mutate'; value: Place; reason?: MutationReason | null; } | { kind: 'MutateConditionally'; value: Place; } | { kind: 'MutateTransitive'; value: Place; } | { kind: 'MutateTransitiveConditionally'; value: Place; } | { kind: 'Capture'; from: Place; into: Place; } | { kind: 'Alias'; from: Place; into: Place; } | { kind: 'MaybeAlias'; from: Place; into: Place; } | { kind: 'Assign'; from: Place; into: Place; } | { kind: 'Create'; into: Place; value: ValueKind; reason: ValueReason; } | { kind: 'CreateFrom'; from: Place; into: Place; } | { kind: 'ImmutableCapture'; from: Place; into: Place; } | { kind: 'Apply'; receiver: Place; function: Place; mutatesFunction: boolean; args: Array; into: Place; signature: FunctionSignature | null; loc: SourceLocation; } | { kind: 'CreateFunction'; captures: Array; function: FunctionExpression | ObjectMethod; into: Place; } | { kind: 'MutateFrozen'; place: Place; error: CompilerDiagnostic; } | { kind: 'MutateGlobal'; place: Place; error: CompilerDiagnostic; } | { kind: 'Impure'; place: Place; error: CompilerDiagnostic; } | { kind: 'Render'; place: Place; }; type MutationReason = { kind: 'AssignCurrentProperty'; }; type AliasingSignature = { receiver: IdentifierId; params: Array; rest: IdentifierId | null; returns: IdentifierId; effects: Array; temporaries: Array; }; type BuiltInType = PrimitiveType | FunctionType | ObjectType; type Type = BuiltInType | PhiType | TypeVar | PolyType | PropType | ObjectMethod$1; type PrimitiveType = { kind: 'Primitive'; }; type FunctionType = { kind: 'Function'; shapeId: string | null; return: Type; isConstructor: boolean; }; type ObjectType = { kind: 'Object'; shapeId: string | null; }; type TypeVar = { kind: 'Type'; id: TypeId; }; type PolyType = { kind: 'Poly'; }; type PhiType = { kind: 'Phi'; operands: Array; }; type PropType = { kind: 'Property'; objectType: Type; objectName: string; propertyName: { kind: 'literal'; value: PropertyLiteral; } | { kind: 'computed'; value: Type; }; }; type ObjectMethod$1 = { kind: 'ObjectMethod'; }; declare const opaqueTypeId: unique symbol; type TypeId = number & { [opaqueTypeId]: 'IdentifierId'; }; type HookKind = 'useContext' | 'useState' | 'useActionState' | 'useReducer' | 'useRef' | 'useEffect' | 'useLayoutEffect' | 'useInsertionEffect' | 'useMemo' | 'useCallback' | 'useTransition' | 'useImperativeHandle' | 'useEffectEvent' | 'Custom'; type FunctionSignature = { positionalParams: Array; restParam: Effect | null; returnType: BuiltInType | PolyType; returnValueKind: ValueKind; returnValueReason?: ValueReason; calleeEffect: Effect; hookKind: HookKind | null; noAlias?: boolean; mutableOnlyIfOperandsAreMutable?: boolean; impure?: boolean; knownIncompatible?: string | null | undefined; canonicalName?: string; aliasing?: AliasingSignature | null | undefined; }; type Global = BuiltInType | PolyType; type ResolvedType = { kind: 'Concrete'; type: ConcreteType; platform: Platform; }; type ComponentType = { kind: 'Component'; props: Map; children: null | T; }; type ConcreteType = { kind: 'Enum'; } | { kind: 'Mixed'; } | { kind: 'Number'; } | { kind: 'String'; } | { kind: 'Boolean'; } | { kind: 'Void'; } | { kind: 'Nullable'; type: T; } | { kind: 'Array'; element: T; } | { kind: 'Set'; element: T; } | { kind: 'Map'; key: T; value: T; } | { kind: 'Function'; typeParameters: null | Array>; params: Array; returnType: T; } | ComponentType | { kind: 'Generic'; id: TypeParameterId; bound: T; } | { kind: 'Object'; id: NominalId; members: Map; } | { kind: 'Tuple'; id: NominalId; members: Array; } | { kind: 'Structural'; id: LinearId; } | { kind: 'Union'; members: Array; } | { kind: 'Instance'; name: string; members: Map; }; type TypeParameter = { name: string; id: TypeParameterId; bound: T; }; declare const opaqueLinearId: unique symbol; type LinearId = number & { [opaqueLinearId]: 'LinearId'; }; declare const opaqueTypeParameterId: unique symbol; type TypeParameterId = number & { [opaqueTypeParameterId]: 'TypeParameterId'; }; declare const opaqueNominalId: unique symbol; type NominalId = number & { [opaqueNominalId]: 'NominalId'; }; type Platform = 'client' | 'server' | 'shared'; interface ITypeEnv { popGeneric(name: string): void; getGeneric(name: string): null | TypeParameter; pushGeneric(name: string, binding: { name: string; id: TypeParameterId; bound: ResolvedType; }): void; getType(id: Identifier): ResolvedType; getTypeOrNull(id: Identifier): ResolvedType | null; setType(id: Identifier, type: ResolvedType): void; nextNominalId(): NominalId; nextTypeParameterId(): TypeParameterId; moduleEnv: Map; addBinding(bindingIdentifier: t.Identifier, type: ResolvedType): void; resolveBinding(bindingIdentifier: t.Identifier): ResolvedType | null; } declare class FlowTypeEnv implements ITypeEnv { #private; moduleEnv: Map; init(env: Environment, source: string): void; setType(identifier: Identifier, type: ResolvedType): void; getType(identifier: Identifier): ResolvedType; getTypeOrNull(identifier: Identifier): ResolvedType | null; getTypeByLoc(loc: SourceLocation): ResolvedType | null; nextNominalId(): NominalId; nextTypeParameterId(): TypeParameterId; addBinding(bindingIdentifier: t.Identifier, type: ResolvedType): void; resolveBinding(bindingIdentifier: t.Identifier): ResolvedType | null; pushGeneric(name: string, generic: TypeParameter): void; popGeneric(name: string): void; getGeneric(name: string): null | TypeParameter; } declare const ExternalFunctionSchema: z.ZodObject<{ source: z.ZodString; importSpecifierName: z.ZodString; }, z.core.$strip>; type ExternalFunction = z.infer; type CompilerMode = 'all_features' | 'no_inferred_memo'; declare const HookSchema: z.ZodObject<{ effectKind: z.ZodEnum; valueKind: z.ZodEnum; noAlias: z.ZodDefault; transitiveMixedData: z.ZodDefault; }, z.core.$strip>; type Hook = z.infer; declare const EnvironmentConfigSchema: z.ZodObject<{ customHooks: z.ZodDefault; valueKind: z.ZodEnum; noAlias: z.ZodDefault; transitiveMixedData: z.ZodDefault; }, z.core.$strip>>>; moduleTypeProvider: z.ZodDefault>; customMacros: z.ZodDefault; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"name">; name: z.ZodString; }, z.core.$strip>]>>], null>]>>>>; enableResetCacheOnSourceFileChanges: z.ZodDefault>; enablePreserveExistingMemoizationGuarantees: z.ZodDefault; validatePreserveExistingMemoizationGuarantees: z.ZodDefault; enablePreserveExistingManualUseMemo: z.ZodDefault; enableForest: z.ZodDefault; enableUseTypeAnnotations: z.ZodDefault; flowTypeProvider: z.ZodDefault>; enableOptionalDependencies: z.ZodDefault; enableFire: z.ZodDefault; enableNameAnonymousFunctions: z.ZodDefault; inferEffectDependencies: z.ZodDefault; autodepsIndex: z.ZodNumber; }, z.core.$strip>>>>; inlineJsxTransform: z.ZodDefault, z.ZodLiteral<"react.transitional.element">]>; globalDevVar: z.ZodString; }, z.core.$strip>>>; validateHooksUsage: z.ZodDefault; validateRefAccessDuringRender: z.ZodDefault; validateNoSetStateInRender: z.ZodDefault; validateNoSetStateInEffects: z.ZodDefault; validateNoDerivedComputationsInEffects: z.ZodDefault; validateNoJSXInTryStatements: z.ZodDefault; validateStaticComponents: z.ZodDefault; validateMemoizedEffectDependencies: z.ZodDefault; validateNoCapitalizedCalls: z.ZodDefault>>; validateBlocklistedImports: z.ZodDefault>>; validateNoImpureFunctionsInRender: z.ZodDefault; validateNoFreezingKnownMutableFunctions: z.ZodDefault; enableAssumeHooksFollowRulesOfReact: z.ZodDefault; enableTransitivelyFreezeFunctionExpressions: z.ZodDefault; enableEmitFreeze: z.ZodDefault>>; enableEmitHookGuards: z.ZodDefault>>; enableInstructionReordering: z.ZodDefault; enableFunctionOutlining: z.ZodDefault; enableJsxOutlining: z.ZodDefault; enableEmitInstrumentForget: z.ZodDefault; gating: z.ZodNullable>; globalGating: z.ZodNullable; }, z.core.$strip>>>; assertValidMutableRanges: z.ZodDefault; enableChangeVariableCodegen: z.ZodDefault; enableMemoizationComments: z.ZodDefault; throwUnknownException__testonly: z.ZodDefault; enableTreatFunctionDepsAsConditional: z.ZodDefault; disableMemoizationForDebugging: z.ZodDefault; enableChangeDetectionForDebugging: z.ZodDefault>>; enableCustomTypeDefinitionForReanimated: z.ZodDefault; hookPattern: z.ZodDefault>; enableTreatRefLikeIdentifiersAsRefs: z.ZodDefault; enableTreatSetIdentifiersAsStateSetters: z.ZodDefault; lowerContextAccess: z.ZodDefault>>; validateNoVoidUseMemo: z.ZodDefault; validateNoDynamicallyCreatedComponentsOrHooks: z.ZodDefault; enableAllowSetStateFromRefsInEffects: z.ZodDefault; }, z.core.$strip>; type EnvironmentConfig = z.infer; type PartialEnvironmentConfig = Partial; type ReactFunctionType = 'Component' | 'Hook' | 'Other'; declare class Environment { #private; logger: Logger | null; filename: string | null; code: string | null; config: EnvironmentConfig; fnType: ReactFunctionType; compilerMode: CompilerMode; programContext: ProgramContext; hasFireRewrite: boolean; hasInferredEffect: boolean; inferredEffectLocations: Set; parentFunction: NodePath; constructor(scope: Scope, fnType: ReactFunctionType, compilerMode: CompilerMode, config: EnvironmentConfig, contextIdentifiers: Set, parentFunction: NodePath, logger: Logger | null, filename: string | null, code: string | null, programContext: ProgramContext); get typeContext(): FlowTypeEnv; get isInferredMemoEnabled(): boolean; get nextIdentifierId(): IdentifierId; get nextBlockId(): BlockId; get nextScopeId(): ScopeId; get scope(): Scope; logErrors(errors: Result): void; isContextIdentifier(node: t.Identifier): boolean; isHoistedIdentifier(node: t.Identifier): boolean; generateGloballyUniqueIdentifierName(name: string | null): ValidatedIdentifier; outlineFunction(fn: HIRFunction, type: ReactFunctionType | null): void; getOutlinedFunctions(): Array<{ fn: HIRFunction; type: ReactFunctionType | null; }>; getGlobalDeclaration(binding: NonLocalBinding, loc: SourceLocation): Global | null; static knownReactModules: ReadonlyArray; getFallthroughPropertyType(receiver: Type, _property: Type): BuiltInType | PolyType | null; getPropertyType(receiver: Type, property: string | number): BuiltInType | PolyType | null; getFunctionSignature(type: FunctionType): FunctionSignature | null; addHoistedIdentifier(node: t.Identifier): void; } declare function validateEnvironmentConfig(partialConfig: PartialEnvironmentConfig): EnvironmentConfig; declare const GeneratedSource: unique symbol; type SourceLocation = t.SourceLocation | typeof GeneratedSource; type ReactiveFunction = { loc: SourceLocation; id: ValidIdentifierName | null; nameHint: string | null; params: Array; generator: boolean; async: boolean; body: ReactiveBlock; env: Environment; directives: Array; }; type ReactiveScopeBlock = { kind: 'scope'; scope: ReactiveScope; instructions: ReactiveBlock; }; type PrunedReactiveScopeBlock = { kind: 'pruned-scope'; scope: ReactiveScope; instructions: ReactiveBlock; }; type ReactiveBlock = Array; type ReactiveStatement = ReactiveInstructionStatement | ReactiveTerminalStatement | ReactiveScopeBlock | PrunedReactiveScopeBlock; type ReactiveInstructionStatement = { kind: 'instruction'; instruction: ReactiveInstruction; }; type ReactiveTerminalStatement = { kind: 'terminal'; terminal: Tterminal; label: { id: BlockId; implicit: boolean; } | null; }; type ReactiveInstruction = { id: InstructionId; lvalue: Place | null; value: ReactiveValue; effects?: Array | null; loc: SourceLocation; }; type ReactiveValue = InstructionValue | ReactiveLogicalValue | ReactiveSequenceValue | ReactiveTernaryValue | ReactiveOptionalCallValue; type ReactiveLogicalValue = { kind: 'LogicalExpression'; operator: t.LogicalExpression['operator']; left: ReactiveValue; right: ReactiveValue; loc: SourceLocation; }; type ReactiveTernaryValue = { kind: 'ConditionalExpression'; test: ReactiveValue; consequent: ReactiveValue; alternate: ReactiveValue; loc: SourceLocation; }; type ReactiveSequenceValue = { kind: 'SequenceExpression'; instructions: Array; id: InstructionId; value: ReactiveValue; loc: SourceLocation; }; type ReactiveOptionalCallValue = { kind: 'OptionalExpression'; id: InstructionId; value: ReactiveValue; optional: boolean; loc: SourceLocation; }; type ReactiveTerminal = ReactiveBreakTerminal | ReactiveContinueTerminal | ReactiveReturnTerminal | ReactiveThrowTerminal | ReactiveSwitchTerminal | ReactiveDoWhileTerminal | ReactiveWhileTerminal | ReactiveForTerminal | ReactiveForOfTerminal | ReactiveForInTerminal | ReactiveIfTerminal | ReactiveLabelTerminal | ReactiveTryTerminal; type ReactiveTerminalTargetKind = 'implicit' | 'labeled' | 'unlabeled'; type ReactiveBreakTerminal = { kind: 'break'; target: BlockId; id: InstructionId; targetKind: ReactiveTerminalTargetKind; loc: SourceLocation; }; type ReactiveContinueTerminal = { kind: 'continue'; target: BlockId; id: InstructionId; targetKind: ReactiveTerminalTargetKind; loc: SourceLocation; }; type ReactiveReturnTerminal = { kind: 'return'; value: Place; id: InstructionId; loc: SourceLocation; }; type ReactiveThrowTerminal = { kind: 'throw'; value: Place; id: InstructionId; loc: SourceLocation; }; type ReactiveSwitchTerminal = { kind: 'switch'; test: Place; cases: Array<{ test: Place | null; block: ReactiveBlock | void; }>; id: InstructionId; loc: SourceLocation; }; type ReactiveDoWhileTerminal = { kind: 'do-while'; loop: ReactiveBlock; test: ReactiveValue; id: InstructionId; loc: SourceLocation; }; type ReactiveWhileTerminal = { kind: 'while'; test: ReactiveValue; loop: ReactiveBlock; id: InstructionId; loc: SourceLocation; }; type ReactiveForTerminal = { kind: 'for'; init: ReactiveValue; test: ReactiveValue; update: ReactiveValue | null; loop: ReactiveBlock; id: InstructionId; loc: SourceLocation; }; type ReactiveForOfTerminal = { kind: 'for-of'; init: ReactiveValue; test: ReactiveValue; loop: ReactiveBlock; id: InstructionId; loc: SourceLocation; }; type ReactiveForInTerminal = { kind: 'for-in'; init: ReactiveValue; loop: ReactiveBlock; id: InstructionId; loc: SourceLocation; }; type ReactiveIfTerminal = { kind: 'if'; test: Place; consequent: ReactiveBlock; alternate: ReactiveBlock | null; id: InstructionId; loc: SourceLocation; }; type ReactiveLabelTerminal = { kind: 'label'; block: ReactiveBlock; id: InstructionId; loc: SourceLocation; }; type ReactiveTryTerminal = { kind: 'try'; block: ReactiveBlock; handlerBinding: Place | null; handler: ReactiveBlock; id: InstructionId; loc: SourceLocation; }; type HIRFunction = { loc: SourceLocation; id: ValidIdentifierName | null; nameHint: string | null; fnType: ReactFunctionType; env: Environment; params: Array; returnTypeAnnotation: t.FlowType | t.TSType | null; returns: Place; context: Array; body: HIR; generator: boolean; async: boolean; directives: Array; aliasingEffects: Array | null; }; type HIR = { entry: BlockId; blocks: Map; }; type BlockKind = 'block' | 'value' | 'loop' | 'sequence' | 'catch'; type BasicBlock = { kind: BlockKind; id: BlockId; instructions: Array; terminal: Terminal; preds: Set; phis: Set; }; type Terminal = UnsupportedTerminal | UnreachableTerminal | ThrowTerminal | ReturnTerminal | GotoTerminal | IfTerminal | BranchTerminal | SwitchTerminal | ForTerminal | ForOfTerminal | ForInTerminal | DoWhileTerminal | WhileTerminal | LogicalTerminal | TernaryTerminal | OptionalTerminal | LabelTerminal | SequenceTerminal | MaybeThrowTerminal | TryTerminal | ReactiveScopeTerminal | PrunedScopeTerminal; type UnsupportedTerminal = { kind: 'unsupported'; id: InstructionId; loc: SourceLocation; fallthrough?: never; }; type UnreachableTerminal = { kind: 'unreachable'; id: InstructionId; loc: SourceLocation; fallthrough?: never; }; type ThrowTerminal = { kind: 'throw'; value: Place; id: InstructionId; loc: SourceLocation; fallthrough?: never; }; type Case = { test: Place | null; block: BlockId; }; type ReturnVariant = 'Void' | 'Implicit' | 'Explicit'; type ReturnTerminal = { kind: 'return'; returnVariant: ReturnVariant; loc: SourceLocation; value: Place; id: InstructionId; fallthrough?: never; effects: Array | null; }; type GotoTerminal = { kind: 'goto'; block: BlockId; variant: GotoVariant; id: InstructionId; loc: SourceLocation; fallthrough?: never; }; declare enum GotoVariant { Break = "Break", Continue = "Continue", Try = "Try" } type IfTerminal = { kind: 'if'; test: Place; consequent: BlockId; alternate: BlockId; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type BranchTerminal = { kind: 'branch'; test: Place; consequent: BlockId; alternate: BlockId; id: InstructionId; loc: SourceLocation; fallthrough: BlockId; }; type SwitchTerminal = { kind: 'switch'; test: Place; cases: Array; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type DoWhileTerminal = { kind: 'do-while'; loop: BlockId; test: BlockId; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type WhileTerminal = { kind: 'while'; loc: SourceLocation; test: BlockId; loop: BlockId; fallthrough: BlockId; id: InstructionId; }; type ForTerminal = { kind: 'for'; loc: SourceLocation; init: BlockId; test: BlockId; update: BlockId | null; loop: BlockId; fallthrough: BlockId; id: InstructionId; }; type ForOfTerminal = { kind: 'for-of'; loc: SourceLocation; init: BlockId; test: BlockId; loop: BlockId; fallthrough: BlockId; id: InstructionId; }; type ForInTerminal = { kind: 'for-in'; loc: SourceLocation; init: BlockId; loop: BlockId; fallthrough: BlockId; id: InstructionId; }; type LogicalTerminal = { kind: 'logical'; operator: t.LogicalExpression['operator']; test: BlockId; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type TernaryTerminal = { kind: 'ternary'; test: BlockId; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type LabelTerminal = { kind: 'label'; block: BlockId; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type OptionalTerminal = { kind: 'optional'; optional: boolean; test: BlockId; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type SequenceTerminal = { kind: 'sequence'; block: BlockId; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type TryTerminal = { kind: 'try'; block: BlockId; handlerBinding: Place | null; handler: BlockId; fallthrough: BlockId; id: InstructionId; loc: SourceLocation; }; type MaybeThrowTerminal = { kind: 'maybe-throw'; continuation: BlockId; handler: BlockId; id: InstructionId; loc: SourceLocation; fallthrough?: never; effects: Array | null; }; type ReactiveScopeTerminal = { kind: 'scope'; fallthrough: BlockId; block: BlockId; scope: ReactiveScope; id: InstructionId; loc: SourceLocation; }; type PrunedScopeTerminal = { kind: 'pruned-scope'; fallthrough: BlockId; block: BlockId; scope: ReactiveScope; id: InstructionId; loc: SourceLocation; }; type Instruction = { id: InstructionId; lvalue: Place; value: InstructionValue; loc: SourceLocation; effects: Array | null; }; type LValue = { place: Place; kind: InstructionKind; }; type LValuePattern = { pattern: Pattern; kind: InstructionKind; }; type ArrayExpression = { kind: 'ArrayExpression'; elements: Array; loc: SourceLocation; }; type Pattern = ArrayPattern | ObjectPattern; type Hole = { kind: 'Hole'; }; type SpreadPattern = { kind: 'Spread'; place: Place; }; type ArrayPattern = { kind: 'ArrayPattern'; items: Array; }; type ObjectPattern = { kind: 'ObjectPattern'; properties: Array; }; type ObjectPropertyKey = { kind: 'string'; name: string; } | { kind: 'identifier'; name: string; } | { kind: 'computed'; name: Place; } | { kind: 'number'; name: number; }; type ObjectProperty = { kind: 'ObjectProperty'; key: ObjectPropertyKey; type: 'property' | 'method'; place: Place; }; type LoweredFunction = { func: HIRFunction; }; type ObjectMethod = { kind: 'ObjectMethod'; loc: SourceLocation; loweredFunc: LoweredFunction; }; declare enum InstructionKind { Const = "Const", Let = "Let", Reassign = "Reassign", Catch = "Catch", HoistedConst = "HoistedConst", HoistedLet = "HoistedLet", HoistedFunction = "HoistedFunction", Function = "Function" } type Phi = { kind: 'Phi'; place: Place; operands: Map; }; type ManualMemoDependency = { root: { kind: 'NamedLocal'; value: Place; } | { kind: 'Global'; identifierName: string; }; path: DependencyPath; }; type StartMemoize = { kind: 'StartMemoize'; manualMemoId: number; deps: Array | null; loc: SourceLocation; }; type FinishMemoize = { kind: 'FinishMemoize'; manualMemoId: number; decl: Place; pruned?: true; loc: SourceLocation; }; type MethodCall = { kind: 'MethodCall'; receiver: Place; property: Place; args: Array; loc: SourceLocation; }; type CallExpression = { kind: 'CallExpression'; callee: Place; args: Array; loc: SourceLocation; typeArguments?: Array; }; type NewExpression = { kind: 'NewExpression'; callee: Place; args: Array; loc: SourceLocation; }; type LoadLocal = { kind: 'LoadLocal'; place: Place; loc: SourceLocation; }; type LoadContext = { kind: 'LoadContext'; place: Place; loc: SourceLocation; }; type InstructionValue = LoadLocal | LoadContext | { kind: 'DeclareLocal'; lvalue: LValue; type: t.FlowType | t.TSType | null; loc: SourceLocation; } | { kind: 'DeclareContext'; lvalue: { kind: InstructionKind.Let | InstructionKind.HoistedConst | InstructionKind.HoistedLet | InstructionKind.HoistedFunction; place: Place; }; loc: SourceLocation; } | StoreLocal | { kind: 'StoreContext'; lvalue: { kind: InstructionKind.Reassign | InstructionKind.Const | InstructionKind.Let | InstructionKind.Function; place: Place; }; value: Place; loc: SourceLocation; } | Destructure | { kind: 'Primitive'; value: number | boolean | string | null | undefined; loc: SourceLocation; } | JSXText | { kind: 'BinaryExpression'; operator: Exclude'>; left: Place; right: Place; loc: SourceLocation; } | NewExpression | CallExpression | MethodCall | { kind: 'UnaryExpression'; operator: Exclude; value: Place; loc: SourceLocation; } | ({ kind: 'TypeCastExpression'; value: Place; type: Type; loc: SourceLocation; } & ({ typeAnnotation: t.FlowType; typeAnnotationKind: 'cast'; } | { typeAnnotation: t.TSType; typeAnnotationKind: 'as' | 'satisfies'; })) | JsxExpression | { kind: 'ObjectExpression'; properties: Array; loc: SourceLocation; } | ObjectMethod | ArrayExpression | { kind: 'JsxFragment'; children: Array; loc: SourceLocation; } | { kind: 'RegExpLiteral'; pattern: string; flags: string; loc: SourceLocation; } | { kind: 'MetaProperty'; meta: string; property: string; loc: SourceLocation; } | { kind: 'PropertyStore'; object: Place; property: PropertyLiteral; value: Place; loc: SourceLocation; } | PropertyLoad | { kind: 'PropertyDelete'; object: Place; property: PropertyLiteral; loc: SourceLocation; } | { kind: 'ComputedStore'; object: Place; property: Place; value: Place; loc: SourceLocation; } | { kind: 'ComputedLoad'; object: Place; property: Place; loc: SourceLocation; } | { kind: 'ComputedDelete'; object: Place; property: Place; loc: SourceLocation; } | LoadGlobal | StoreGlobal | FunctionExpression | { kind: 'TaggedTemplateExpression'; tag: Place; value: { raw: string; cooked?: string; }; loc: SourceLocation; } | { kind: 'TemplateLiteral'; subexprs: Array; quasis: Array<{ raw: string; cooked?: string; }>; loc: SourceLocation; } | { kind: 'Await'; value: Place; loc: SourceLocation; } | { kind: 'GetIterator'; collection: Place; loc: SourceLocation; } | { kind: 'IteratorNext'; iterator: Place; collection: Place; loc: SourceLocation; } | { kind: 'NextPropertyOf'; value: Place; loc: SourceLocation; } | { kind: 'PrefixUpdate'; lvalue: Place; operation: t.UpdateExpression['operator']; value: Place; loc: SourceLocation; } | { kind: 'PostfixUpdate'; lvalue: Place; operation: t.UpdateExpression['operator']; value: Place; loc: SourceLocation; } | { kind: 'Debugger'; loc: SourceLocation; } | StartMemoize | FinishMemoize | { kind: 'UnsupportedNode'; node: t.Node; loc: SourceLocation; }; type JsxExpression = { kind: 'JsxExpression'; tag: Place | BuiltinTag; props: Array; children: Array | null; loc: SourceLocation; openingLoc: SourceLocation; closingLoc: SourceLocation; }; type JsxAttribute = { kind: 'JsxSpreadAttribute'; argument: Place; } | { kind: 'JsxAttribute'; name: string; place: Place; }; type FunctionExpression = { kind: 'FunctionExpression'; name: ValidIdentifierName | null; nameHint: string | null; loweredFunc: LoweredFunction; type: 'ArrowFunctionExpression' | 'FunctionExpression' | 'FunctionDeclaration'; loc: SourceLocation; }; type Destructure = { kind: 'Destructure'; lvalue: LValuePattern; value: Place; loc: SourceLocation; }; type Place = { kind: 'Identifier'; identifier: Identifier; effect: Effect; reactive: boolean; loc: SourceLocation; }; type JSXText = { kind: 'JSXText'; value: string; loc: SourceLocation; }; type StoreLocal = { kind: 'StoreLocal'; lvalue: LValue; value: Place; type: t.FlowType | t.TSType | null; loc: SourceLocation; }; type PropertyLoad = { kind: 'PropertyLoad'; object: Place; property: PropertyLiteral; loc: SourceLocation; }; type LoadGlobal = { kind: 'LoadGlobal'; binding: NonLocalBinding; loc: SourceLocation; }; type StoreGlobal = { kind: 'StoreGlobal'; name: string; value: Place; loc: SourceLocation; }; type BuiltinTag = { kind: 'BuiltinTag'; name: string; loc: SourceLocation; }; type MutableRange = { start: InstructionId; end: InstructionId; }; type NonLocalImportSpecifier = { kind: 'ImportSpecifier'; name: string; module: string; imported: string; }; type NonLocalBinding = { kind: 'ImportDefault'; name: string; module: string; } | { kind: 'ImportNamespace'; name: string; module: string; } | NonLocalImportSpecifier | { kind: 'ModuleLocal'; name: string; } | { kind: 'Global'; name: string; }; type Identifier = { id: IdentifierId; declarationId: DeclarationId; name: IdentifierName | null; mutableRange: MutableRange; scope: ReactiveScope | null; type: Type; loc: SourceLocation; }; type IdentifierName = ValidatedIdentifier | PromotedIdentifier; type ValidatedIdentifier = { kind: 'named'; value: ValidIdentifierName; }; type PromotedIdentifier = { kind: 'promoted'; value: string; }; declare const opaqueValidIdentifierName: unique symbol; type ValidIdentifierName = string & { [opaqueValidIdentifierName]: 'ValidIdentifierName'; }; declare enum ValueReason { Global = "global", JsxCaptured = "jsx-captured", HookCaptured = "hook-captured", HookReturn = "hook-return", Effect = "effect", KnownReturnSignature = "known-return-signature", Context = "context", State = "state", ReducerState = "reducer-state", ReactiveFunctionArgument = "reactive-function-argument", Other = "other" } declare enum ValueKind { MaybeFrozen = "maybefrozen", Frozen = "frozen", Primitive = "primitive", Global = "global", Mutable = "mutable", Context = "context" } declare enum Effect { Unknown = "", Freeze = "freeze", Read = "read", Capture = "capture", ConditionallyMutateIterator = "mutate-iterator?", ConditionallyMutate = "mutate?", Mutate = "mutate", Store = "store" } type ReactiveScope = { id: ScopeId; range: MutableRange; dependencies: ReactiveScopeDependencies; declarations: Map; reassignments: Set; earlyReturnValue: { value: Identifier; loc: SourceLocation; label: BlockId; } | null; merged: Set; loc: SourceLocation; }; type ReactiveScopeDependencies = Set; type ReactiveScopeDeclaration = { identifier: Identifier; scope: ReactiveScope; }; declare const opaquePropertyLiteral: unique symbol; type PropertyLiteral = (string | number) & { [opaquePropertyLiteral]: 'PropertyLiteral'; }; type DependencyPathEntry = { property: PropertyLiteral; optional: boolean; }; type DependencyPath = Array; type ReactiveScopeDependency = { identifier: Identifier; reactive: boolean; path: DependencyPath; }; declare const opaqueBlockId: unique symbol; type BlockId = number & { [opaqueBlockId]: 'BlockId'; }; declare const opaqueScopeId: unique symbol; type ScopeId = number & { [opaqueScopeId]: 'ScopeId'; }; declare const opaqueIdentifierId: unique symbol; type IdentifierId = number & { [opaqueIdentifierId]: 'IdentifierId'; }; declare const opageDeclarationId: unique symbol; type DeclarationId = number & { [opageDeclarationId]: 'DeclarationId'; }; declare const opaqueInstructionId: unique symbol; type InstructionId = number & { [opaqueInstructionId]: 'IdentifierId'; }; type Options = { indent: number; }; declare function printFunctionWithOutlined(fn: HIRFunction): string; declare function printHIR(ir: HIR, options?: Options | null): string; declare enum ErrorSeverity { Error = "Error", Warning = "Warning", Hint = "Hint", Off = "Off" } type CompilerDiagnosticOptions = { category: ErrorCategory; reason: string; description: string | null; details: Array; suggestions?: Array | null | undefined; }; type CompilerDiagnosticDetail = { kind: 'error'; loc: SourceLocation | null; message: string | null; } | { kind: 'hint'; message: string; }; declare enum CompilerSuggestionOperation { InsertBefore = 0, InsertAfter = 1, Remove = 2, Replace = 3 } type CompilerSuggestion = { op: CompilerSuggestionOperation.InsertAfter | CompilerSuggestionOperation.InsertBefore | CompilerSuggestionOperation.Replace; range: [number, number]; description: string; text: string; } | { op: CompilerSuggestionOperation.Remove; range: [number, number]; description: string; }; type CompilerErrorDetailOptions = { category: ErrorCategory; reason: string; description?: string | null | undefined; loc: SourceLocation | null; suggestions?: Array | null | undefined; }; type PrintErrorMessageOptions = { eslint: boolean; }; declare class CompilerDiagnostic { options: CompilerDiagnosticOptions; constructor(options: CompilerDiagnosticOptions); static create(options: Omit): CompilerDiagnostic; get reason(): CompilerDiagnosticOptions['reason']; get description(): CompilerDiagnosticOptions['description']; get severity(): ErrorSeverity; get suggestions(): CompilerDiagnosticOptions['suggestions']; get category(): ErrorCategory; withDetails(...details: Array): CompilerDiagnostic; primaryLocation(): SourceLocation | null; printErrorMessage(source: string, options: PrintErrorMessageOptions): string; toString(): string; } declare class CompilerErrorDetail { options: CompilerErrorDetailOptions; constructor(options: CompilerErrorDetailOptions); get reason(): CompilerErrorDetailOptions['reason']; get description(): CompilerErrorDetailOptions['description']; get severity(): ErrorSeverity; get loc(): CompilerErrorDetailOptions['loc']; get suggestions(): CompilerErrorDetailOptions['suggestions']; get category(): ErrorCategory; primaryLocation(): SourceLocation | null; printErrorMessage(source: string, options: PrintErrorMessageOptions): string; toString(): string; } declare class CompilerError extends Error { details: Array; disabledDetails: Array; printedMessage: string | null; static invariant(condition: unknown, options: Omit): asserts condition; static throwDiagnostic(options: CompilerDiagnosticOptions): never; static throwTodo(options: Omit): never; static throwInvalidJS(options: Omit): never; static throwInvalidReact(options: CompilerErrorDetailOptions): never; static throwInvalidConfig(options: Omit): never; static throw(options: CompilerErrorDetailOptions): never; constructor(...args: Array); get message(): string; set message(_message: string); toString(): string; withPrintedMessage(source: string, options: PrintErrorMessageOptions): CompilerError; printErrorMessage(source: string, options: PrintErrorMessageOptions): string; merge(other: CompilerError): void; pushDiagnostic(diagnostic: CompilerDiagnostic): void; push(options: CompilerErrorDetailOptions): CompilerErrorDetail; pushErrorDetail(detail: CompilerErrorDetail): CompilerErrorDetail; hasAnyErrors(): boolean; asResult(): Result; hasErrors(): boolean; hasWarning(): boolean; hasHints(): boolean; } declare enum ErrorCategory { Hooks = "Hooks", CapitalizedCalls = "CapitalizedCalls", StaticComponents = "StaticComponents", UseMemo = "UseMemo", Factories = "Factories", PreserveManualMemo = "PreserveManualMemo", IncompatibleLibrary = "IncompatibleLibrary", Immutability = "Immutability", Globals = "Globals", Refs = "Refs", EffectDependencies = "EffectDependencies", EffectSetState = "EffectSetState", EffectDerivationsOfState = "EffectDerivationsOfState", ErrorBoundaries = "ErrorBoundaries", Purity = "Purity", RenderSetState = "RenderSetState", Invariant = "Invariant", Todo = "Todo", Syntax = "Syntax", UnsupportedSyntax = "UnsupportedSyntax", Config = "Config", Gating = "Gating", Suppression = "Suppression", AutomaticEffectDependencies = "AutomaticEffectDependencies", Fire = "Fire", FBT = "FBT" } type LintRule = { category: ErrorCategory; severity: ErrorSeverity; name: string; description: string; recommended: boolean; }; declare const LintRules: Array; type CodegenFunction = { type: 'CodegenFunction'; id: t.Identifier | null; nameHint: string | null; params: t.FunctionDeclaration['params']; body: t.BlockStatement; generator: boolean; async: boolean; loc: SourceLocation; memoSlotsUsed: number; memoBlocks: number; memoValues: number; prunedMemoBlocks: number; prunedMemoValues: number; outlined: Array<{ fn: CodegenFunction; type: ReactFunctionType | null; }>; hasInferredEffect: boolean; inferredEffectLocations: Set; hasFireRewrite: boolean; }; declare function printReactiveFunctionWithOutlined(fn: ReactiveFunction): string; declare function printReactiveFunction(fn: ReactiveFunction): string; type CompilerPipelineValue = { kind: 'ast'; name: string; value: CodegenFunction; } | { kind: 'hir'; name: string; value: HIRFunction; } | { kind: 'reactive'; name: string; value: ReactiveFunction; } | { kind: 'debug'; name: string; value: string; }; declare function compileFn(func: NodePath, config: EnvironmentConfig, fnType: ReactFunctionType, mode: CompilerMode, programContext: ProgramContext, logger: Logger | null, filename: string | null, code: string | null): CodegenFunction; declare const PanicThresholdOptionsSchema: z.ZodEnum<{ none: "none"; all_errors: "all_errors"; critical_errors: "critical_errors"; }>; type PanicThresholdOptions = z.infer; declare const DynamicGatingOptionsSchema: z.ZodObject<{ source: z.ZodString; }, z.core.$strip>; type DynamicGatingOptions = z.infer; declare const CustomOptOutDirectiveSchema: z.ZodDefault>>; type CustomOptOutDirective = z.infer; type PluginOptions = Partial<{ environment: Partial; logger: Logger | null; gating: ExternalFunction | null; dynamicGating: DynamicGatingOptions | null; panicThreshold: PanicThresholdOptions; noEmit: boolean; compilationMode: CompilationMode; eslintSuppressionRules: Array | null | undefined; flowSuppressions: boolean; ignoreUseNoForget: boolean; customOptOutDirectives: CustomOptOutDirective; sources: Array | ((filename: string) => boolean) | null; enableReanimatedCheck: boolean; target: CompilerReactTarget; }>; type ParsedPluginOptions = Required> & { environment: EnvironmentConfig; }; declare const CompilerReactTargetSchema: z.ZodUnion, z.ZodLiteral<"18">, z.ZodLiteral<"19">, z.ZodObject<{ kind: z.ZodLiteral<"donotuse_meta_internal">; runtimeModule: z.ZodDefault; }, z.core.$strip>]>; type CompilerReactTarget = z.infer; declare const CompilationModeSchema: z.ZodEnum<{ syntax: "syntax"; infer: "infer"; annotation: "annotation"; all: "all"; }>; type CompilationMode = z.infer; type LoggerEvent = CompileSuccessEvent | CompileErrorEvent | CompileDiagnosticEvent | CompileSkipEvent | PipelineErrorEvent | TimingEvent | AutoDepsDecorationsEvent | AutoDepsEligibleEvent; type CompileErrorEvent = { kind: 'CompileError'; fnLoc: t.SourceLocation | null; detail: CompilerErrorDetail | CompilerDiagnostic; }; type CompileDiagnosticEvent = { kind: 'CompileDiagnostic'; fnLoc: t.SourceLocation | null; detail: Omit, 'suggestions'>; }; type CompileSuccessEvent = { kind: 'CompileSuccess'; fnLoc: t.SourceLocation | null; fnName: string | null; memoSlots: number; memoBlocks: number; memoValues: number; prunedMemoBlocks: number; prunedMemoValues: number; }; type CompileSkipEvent = { kind: 'CompileSkip'; fnLoc: t.SourceLocation | null; reason: string; loc: t.SourceLocation | null; }; type PipelineErrorEvent = { kind: 'PipelineError'; fnLoc: t.SourceLocation | null; data: string; }; type TimingEvent = { kind: 'Timing'; measurement: PerformanceMeasure; }; type AutoDepsDecorationsEvent = { kind: 'AutoDepsDecorations'; fnLoc: t.SourceLocation; decorations: Array; }; type AutoDepsEligibleEvent = { kind: 'AutoDepsEligible'; fnLoc: t.SourceLocation; depArrayLoc: t.SourceLocation; }; type Logger = { logEvent: (filename: string | null, event: LoggerEvent) => void; debugLogIRs?: (value: CompilerPipelineValue) => void; }; declare function parsePluginOptions(obj: unknown): ParsedPluginOptions; type CompilerPass = { opts: ParsedPluginOptions; filename: string | null; comments: Array; code: string | null; }; declare const OPT_IN_DIRECTIVES: Set; declare const OPT_OUT_DIRECTIVES: Set; declare function tryFindDirectiveEnablingMemoization(directives: Array, opts: ParsedPluginOptions): Result; declare function findDirectiveDisablingMemoization(directives: Array, { customOptOutDirectives }: PluginOptions): t.Directive | null; type BabelFn = NodePath$1 | NodePath$1 | NodePath$1; type CompileProgramMetadata = { retryErrors: Array<{ fn: BabelFn; error: CompilerError; }>; inferredEffectLocations: Set; }; declare function compileProgram(program: NodePath$1, pass: CompilerPass): CompileProgramMetadata | null; type SuppressionRange = { disableComment: t.Comment; enableComment: t.Comment | null; source: SuppressionSource; }; type SuppressionSource = 'Eslint' | 'Flow'; type ProgramContextOptions = { program: NodePath$1; suppressions: Array; opts: ParsedPluginOptions; filename: string | null; code: string | null; hasModuleScopeOptOut: boolean; }; declare class ProgramContext { scope: Scope; opts: ParsedPluginOptions; filename: string | null; code: string | null; reactRuntimeModule: string; suppressions: Array; hasModuleScopeOptOut: boolean; alreadyCompiled: WeakSet | Set; knownReferencedNames: Set; imports: Map>; retryErrors: Array<{ fn: BabelFn; error: CompilerError; }>; inferredEffectLocations: Set; constructor({ program, suppressions, opts, filename, code, hasModuleScopeOptOut, }: ProgramContextOptions); isHookName(name: string): boolean; hasReference(name: string): boolean; newUid(name: string): string; addMemoCacheImport(): NonLocalImportSpecifier; addImportSpecifier({ source: module, importSpecifierName: specifier }: ExternalFunction, nameHint?: string): NonLocalImportSpecifier; addNewReference(name: string): void; assertGlobalBinding(name: string, localScope?: Scope): Result; logEvent(event: LoggerEvent): void; } declare function runBabelPluginReactCompiler(text: string, file: string, language: 'flow' | 'typescript', options: PluginOptions | null, includeAst?: boolean): BabelCore.BabelFileResult; declare function parseConfigPragmaForTests(pragma: string, defaults: { compilationMode: CompilationMode; environment?: PartialEnvironmentConfig; }): PluginOptions; declare function BabelPluginReactCompiler(_babel: typeof BabelCore): BabelCore.PluginObj; declare global { } export { CompilerDiagnostic, type CompilerDiagnosticDetail, type CompilerDiagnosticOptions, CompilerError, CompilerErrorDetail, type CompilerErrorDetailOptions, type CompilerPipelineValue, CompilerSuggestionOperation, Effect, type EnvironmentConfig, ErrorCategory, ErrorSeverity, type ExternalFunction, type Hook, type LintRule, LintRules, type Logger, type LoggerEvent, OPT_IN_DIRECTIVES, OPT_OUT_DIRECTIVES, type PluginOptions, ProgramContext, type SourceLocation, ValueKind, ValueReason, compileFn as compile, compileProgram, BabelPluginReactCompiler as default, findDirectiveDisablingMemoization, tryFindDirectiveEnablingMemoization as findDirectiveEnablingMemoization, parseConfigPragmaForTests, parsePluginOptions, printFunctionWithOutlined, printHIR, printReactiveFunction, printReactiveFunctionWithOutlined, runBabelPluginReactCompiler, validateEnvironmentConfig };