[compiler][ez] Add validation for auto-deps config (#31813)

numRequiredArgs has to be more than 0 and the pass depends on that

--
This commit is contained in:
Jordan Brown 2025-03-03 14:39:03 -05:00 committed by GitHub
parent 605a880c8c
commit a1f157e9a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -285,7 +285,7 @@ const EnvironmentConfigSchema = z.object({
z.array(
z.object({
function: ExternalFunctionSchema,
numRequiredArgs: z.number(),
numRequiredArgs: z.number().min(1, 'numRequiredArgs must be > 0'),
}),
),
)

View File

@ -24,6 +24,24 @@ describe('parseConfigPragma()', () => {
);
});
it('effect autodeps config must have at least 1 required argument', () => {
expect(() => {
validateEnvironmentConfig({
inferEffectDependencies: [
{
function: {
source: 'react',
importSpecifierName: 'useEffect',
},
numRequiredArgs: 0,
},
],
} as any);
}).toThrowErrorMatchingInlineSnapshot(
`"InvalidConfig: Could not validate environment config. Update React Compiler config to fix the error. Validation error: numRequiredArgs must be > 0 at "inferEffectDependencies[0].numRequiredArgs""`,
);
});
it('can parse stringy enums', () => {
const stringyHook = {
effectKind: 'freeze',