@@ -22091,8 +22091,9 @@ const BuiltInStartTransitionId = 'BuiltInStartTransition';
2209122091const BuiltInFireId = 'BuiltInFire';
2209222092const BuiltInFireFunctionId = 'BuiltInFireFunction';
2209322093const BuiltInUseEffectEventId = 'BuiltInUseEffectEvent';
22094- const BuiltinEffectEventId = 'BuiltInEffectEventFunction';
22094+ const BuiltInEffectEventId = 'BuiltInEffectEventFunction';
2209522095const BuiltInAutodepsId = 'BuiltInAutoDepsId';
22096+ const BuiltInEventHandlerId = 'BuiltInEventHandlerId';
2209622097const ReanimatedSharedValueId = 'ReanimatedSharedValueId';
2209722098const BUILTIN_SHAPES = new Map();
2209822099addObject(BUILTIN_SHAPES, BuiltInPropsId, [
@@ -22739,7 +22740,14 @@ addFunction(BUILTIN_SHAPES, [], {
2273922740 returnType: { kind: 'Poly' },
2274022741 calleeEffect: Effect.ConditionallyMutate,
2274122742 returnValueKind: ValueKind.Mutable,
22742- }, BuiltinEffectEventId);
22743+ }, BuiltInEffectEventId);
22744+ addFunction(BUILTIN_SHAPES, [], {
22745+ positionalParams: [],
22746+ restParam: Effect.ConditionallyMutate,
22747+ returnType: { kind: 'Poly' },
22748+ calleeEffect: Effect.ConditionallyMutate,
22749+ returnValueKind: ValueKind.Mutable,
22750+ }, BuiltInEventHandlerId);
2274322751addObject(BUILTIN_SHAPES, BuiltInMixedReadonlyId, [
2274422752 [
2274522753 'toString',
@@ -31169,7 +31177,7 @@ const REACT_APIS = [
3116931177 returnType: {
3117031178 kind: 'Function',
3117131179 return: { kind: 'Poly' },
31172- shapeId: BuiltinEffectEventId ,
31180+ shapeId: BuiltInEffectEventId ,
3117331181 isConstructor: false,
3117431182 },
3117531183 calleeEffect: Effect.Read,
@@ -32192,6 +32200,7 @@ const EnvironmentConfigSchema = v4.z.object({
3219232200 validateNoVoidUseMemo: v4.z.boolean().default(true),
3219332201 validateNoDynamicallyCreatedComponentsOrHooks: v4.z.boolean().default(false),
3219432202 enableAllowSetStateFromRefsInEffects: v4.z.boolean().default(true),
32203+ enableInferEventHandlers: v4.z.boolean().default(false),
3219532204});
3219632205class Environment {
3219732206 constructor(scope, fnType, compilerMode, config, contextIdentifiers, parentFunction, logger, filename, code, programContext) {
@@ -41100,6 +41109,7 @@ function applyEffect(context, state, _effect, initialized, effects) {
4110041109 case ValueKind.Primitive: {
4110141110 break;
4110241111 }
41112+ case ValueKind.MaybeFrozen:
4110341113 case ValueKind.Frozen: {
4110441114 sourceType = 'frozen';
4110541115 break;
@@ -48354,6 +48364,25 @@ function* generateInstructionTypes(env, names, instr) {
4835448364 }
4835548365 }
4835648366 }
48367+ if (env.config.enableInferEventHandlers) {
48368+ if (value.kind === 'JsxExpression' &&
48369+ value.tag.kind === 'BuiltinTag' &&
48370+ !value.tag.name.includes('-')) {
48371+ for (const prop of value.props) {
48372+ if (prop.kind === 'JsxAttribute' &&
48373+ prop.name.startsWith('on') &&
48374+ prop.name.length > 2 &&
48375+ prop.name[2] === prop.name[2].toUpperCase()) {
48376+ yield equation(prop.place.identifier.type, {
48377+ kind: 'Function',
48378+ shapeId: BuiltInEventHandlerId,
48379+ return: makeType(),
48380+ isConstructor: false,
48381+ });
48382+ }
48383+ }
48384+ }
48385+ }
4835748386 yield equation(left, { kind: 'Object', shapeId: BuiltInJsxId });
4835848387 break;
4835948388 }
@@ -49277,6 +49306,10 @@ function refTypeOfType(place) {
4927749306 return { kind: 'None' };
4927849307 }
4927949308}
49309+ function isEventHandlerType(identifier) {
49310+ const type = identifier.type;
49311+ return type.kind === 'Function' && type.shapeId === BuiltInEventHandlerId;
49312+ }
4928049313function tyEqual(a, b) {
4928149314 if (a.kind !== b.kind) {
4928249315 return false;
@@ -49563,8 +49596,10 @@ function validateNoRefAccessInRenderImpl(fn, env) {
4956349596 }
4956449597 if (!didError) {
4956549598 const isRefLValue = isUseRefType(instr.lvalue.identifier);
49599+ const isEventHandlerLValue = isEventHandlerType(instr.lvalue.identifier);
4956649600 for (const operand of eachInstructionValueOperand(instr.value)) {
4956749601 if (isRefLValue ||
49602+ isEventHandlerLValue ||
4956849603 (hookKind != null &&
4956949604 hookKind !== 'useState' &&
4957049605 hookKind !== 'useReducer')) {
0 commit comments