Skip to content

issue: resolver is converting z.coerce.date().nullish() to unknown instead of Date | null | undefined #815

@bloodykheeng

Description

@bloodykheeng

Version Number

"@hookform/resolvers": "^5.2.1",

Codesandbox/Expo snack

tsx nextjs

Steps to reproduce

project_data: z.coerce.date().nullish(),

when i put that in my zod then i infer then i resolve
// ✅ TypeScript Type for Form Fields
type FormData = z.infer;

const AgentVisitForm: React.FC<{
handleFormSubmit: (FormData: FormData | null) => any;
formMutation: any;
initialData?: FormData;
}> = ({ handleFormSubmit, formMutation, initialData = defaultValues }) => {
const {
handleSubmit,
control,
watch,
setValue,
formState: { errors },
} = useForm({
resolver: zodResolver(formSchema),
defaultValues: initialData,
});

Expected behaviour

resolver schema is telling me project_date is unknown
yet infer schema is telling me project_date is Date | null | undefined

so i expected the resolver schema to tell me this too Date | null | undefined
since its what i defined in my zod

What browsers are you seeing the problem on?

Chrome

Relevant log output

"@hookform/resolvers": "^5.2.1",
"next": "15.4.6",
 "zod": "^4.0.17"

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions