mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
[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:
parent
605a880c8c
commit
a1f157e9a9
|
|
@ -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'),
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user