Z
Zod2mo ago
neurotech

neurotech - Hi everyone, I just updated to zod ...

Hi everyone, I just updated to zod 4.0.15 and everything's working well except for one last remaining file in my project. I have a generic component, InputFormField, that can be imbued with a schema, i.e.:
<InputFormField<typeof FormSchema>
control={form.control}
name="title"
label="Asset Name"
required
/>
<InputFormField<typeof FormSchema>
control={form.control}
name="title"
label="Asset Name"
required
/>
This worked well in zod 3, but since upgrading I'm getting errors in the interface for the component's props, specifcally the control prop:
interface InputFormFieldProps<T extends z.ZodTypeAny> {
control: Control<z.infer<T>>;
name: Path<z.infer<T>>;
label: string;
className?: string;
inputType?: HTMLInputTypeAttribute;
placeholder?: string;
required?: boolean;
}
interface InputFormFieldProps<T extends z.ZodTypeAny> {
control: Control<z.infer<T>>;
name: Path<z.infer<T>>;
label: string;
className?: string;
inputType?: HTMLInputTypeAttribute;
placeholder?: string;
required?: boolean;
}
Type 'output<T>' does not satisfy the constraint 'FieldValues'.
Type 'unknown' is not assignable to type 'FieldValues'.ts(2344)

(alias) type infer<T> = T extends {
_zod: {
output: any;
};
} ? T["_zod"]["output"] : unknown
export infer
Type 'output<T>' does not satisfy the constraint 'FieldValues'.
Type 'unknown' is not assignable to type 'FieldValues'.ts(2344)

(alias) type infer<T> = T extends {
_zod: {
output: any;
};
} ? T["_zod"]["output"] : unknown
export infer
Does anyone know how to resolve this?
Solution:
Ahhh... wondering if this might be a react-hook-form issue
Jump to solution
1 Reply
Solution
neurotech
neurotech2mo ago
Ahhh... wondering if this might be a react-hook-form issue

Did you find this page helpful?