-
-
Notifications
You must be signed in to change notification settings - Fork 196
Open
Description
Version Number
5.2.1
Steps to reproduce
import { z } from 'zod/v4';
import { zodResolver } from '@hookform/resolvers/zod';
import { useForm } from 'react-hook-form';
const schema = z.object({ name: z.string() });
const methods = useForm({
resolver: zodResolver(schema),
});
Here's I can't use the schema inside the zodResolver, typescript complains:
No overload matches this call.
Overload 1 of 4, '(schema: Zod3Type<{ name: string; }, { name: string; }>, schemaOptions?: ParseParams | undefined, resolverOptions?: NonRawResolverOptions | undefined): Resolver<...>', gave the following error.
Argument of type 'ZodObject<{ name: ZodString; }, $strip>' is not assignable to parameter of type 'Zod3Type<{ name: string; }, { name: string; }>'.
Types of property '_def' are incompatible.
Property 'typeName' is missing in type '$ZodObjectDef<{ name: ZodString; }>' but required in type '{ typeName: string; }'.
Overload 2 of 4, '(schema: $ZodType<unknown, FieldValues, $ZodTypeInternals<unknown, FieldValues>>, schemaOptions?: ParseContext<$ZodIssue> | undefined, resolverOptions?: NonRawResolverOptions | undefined): Resolver<...>', gave the following error.
Argument of type 'ZodObject<{ name: ZodString; }, $strip>' is not assignable to parameter of type '$ZodType<unknown, FieldValues, $ZodTypeInternals<unknown, FieldValues>>'.
The types of '_zod.version.minor' are incompatible between these types.
Type '1' is not assignable to type '0'.ts(2769)
Heres my package.json:
"@hookform/resolvers": "^5.2.1",
"react-hook-form": "^7.62.0",
"typescript": "^5.9.2"
bennajah and marcpicaudAmmar-1999, camerondubas, bernaferrari and jcwillox
Metadata
Metadata
Assignees
Labels
No labels