@@ -30111,7 +30111,7 @@ const EnvironmentConfigSchema = zod.z.object({
3011130111 inferEffectDependencies: zod.z
3011230112 .nullable(zod.z.array(zod.z.object({
3011330113 function: ExternalFunctionSchema,
30114- numRequiredArgs : zod.z.number().min(1, 'numRequiredArgs must be > 0'),
30114+ autodepsIndex : zod.z.number().min(1, 'autodepsIndex must be > 0'),
3011530115 })))
3011630116 .default(null),
3011730117 inlineJsxTransform: ReactElementSymbolSchema.nullable().default(null),
@@ -45178,7 +45178,7 @@ function inferEffectDependencies(fn) {
4517845178 const autodepFnConfigs = new Map();
4517945179 for (const effectTarget of fn.env.config.inferEffectDependencies) {
4518045180 const moduleTargets = getOrInsertWith(autodepFnConfigs, effectTarget.function.source, () => new Map());
45181- moduleTargets.set(effectTarget.function.importSpecifierName, effectTarget.numRequiredArgs );
45181+ moduleTargets.set(effectTarget.function.importSpecifierName, effectTarget.autodepsIndex );
4518245182 }
4518345183 const autodepFnLoads = new Map();
4518445184 const autodepModuleLoads = new Map();
@@ -45240,8 +45240,10 @@ function inferEffectDependencies(fn) {
4524045240 const autodepsArgIndex = value.args.findIndex(arg => arg.kind === 'Identifier' &&
4524145241 arg.identifier.type.kind === 'Object' &&
4524245242 arg.identifier.type.shapeId === BuiltInAutodepsId);
45243- if (value.args.length > 1 &&
45244- autodepsArgIndex > 0 &&
45243+ const autodepsArgExpectedIndex = autodepFnLoads.get(callee.identifier.id);
45244+ if (value.args.length > 0 &&
45245+ autodepsArgExpectedIndex != null &&
45246+ autodepsArgIndex === autodepsArgExpectedIndex &&
4524545247 autodepFnLoads.has(callee.identifier.id) &&
4524645248 value.args[0].kind === 'Identifier') {
4524745249 const effectDeps = [];
@@ -51590,7 +51592,30 @@ function throwInvalidReact(options, { logger, filename }) {
5159051592 });
5159151593 CompilerError.throw(detail);
5159251594}
51593- function assertValidEffectImportReference(numArgs, paths, context) {
51595+ function isAutodepsSigil(arg) {
51596+ if (arg.isIdentifier() && arg.node.name === 'AUTODEPS') {
51597+ const binding = arg.scope.getBinding(arg.node.name);
51598+ if (binding && binding.path.isImportSpecifier()) {
51599+ const importSpecifier = binding.path.node;
51600+ if (importSpecifier.imported.type === 'Identifier') {
51601+ return importSpecifier.imported.name === 'AUTODEPS';
51602+ }
51603+ }
51604+ return false;
51605+ }
51606+ if (arg.isMemberExpression() && !arg.node.computed) {
51607+ const object = arg.get('object');
51608+ const property = arg.get('property');
51609+ if (object.isIdentifier() &&
51610+ object.node.name === 'React' &&
51611+ property.isIdentifier() &&
51612+ property.node.name === 'AUTODEPS') {
51613+ return true;
51614+ }
51615+ }
51616+ return false;
51617+ }
51618+ function assertValidEffectImportReference(autodepsIndex, paths, context) {
5159451619 var _a;
5159551620 for (const path of paths) {
5159651621 const parent = path.parentPath;
@@ -51599,7 +51624,8 @@ function assertValidEffectImportReference(numArgs, paths, context) {
5159951624 const maybeCalleeLoc = path.node.loc;
5160051625 const hasInferredEffect = maybeCalleeLoc != null &&
5160151626 context.inferredEffectLocations.has(maybeCalleeLoc);
51602- if (args.length === numArgs && !hasInferredEffect) {
51627+ const hasAutodepsArg = args.some(isAutodepsSigil);
51628+ if (hasAutodepsArg && !hasInferredEffect) {
5160351629 const maybeErrorDiagnostic = matchCompilerDiagnostic(path, context.transformErrors);
5160451630 throwInvalidReact({
5160551631 reason: '[InferEffectDependencies] React Compiler is unable to infer dependencies of this effect. ' +
@@ -51637,9 +51663,9 @@ function validateNoUntransformedReferences(path, filename, logger, env, compileR
5163751663 }
5163851664 }
5163951665 if (env.inferEffectDependencies) {
51640- for (const { function: { source, importSpecifierName }, numRequiredArgs , } of env.inferEffectDependencies) {
51666+ for (const { function: { source, importSpecifierName }, autodepsIndex , } of env.inferEffectDependencies) {
5164151667 const module = getOrInsertWith(moduleLoadChecks, source, () => new Map());
51642- module.set(importSpecifierName, assertValidEffectImportReference.bind(null, numRequiredArgs ));
51668+ module.set(importSpecifierName, assertValidEffectImportReference.bind(null, autodepsIndex ));
5164351669 }
5164451670 }
5164551671 if (moduleLoadChecks.size > 0) {
0 commit comments