What <ShippingFormInputs> actually does useForm < ShippingFormInputs >() This is NOT runtime code . It only tells TypeScript: “This form should only accept fields defined in ShippingFormInputs.” 📦 Example type type ShippingFormInputs = { email: string ; age: number ; }; So valid fields are only: "email" "age" ❌ How it catches typos Example mistake: register ( "emial" ); // ❌ typo 👉 TypeScript immediately checks: “Is 'emial' a key in ShippingFormInputs?” Answer: ❌ NO So it shows error: Argument of type '"emial"' is not assignable to parameter of type '"email" | "age"'
Let’s make it super clear with a real example. You have this: type ShippingFormInputs = { email: string ; age: number ; }; and this Zod schema: const shippingFormSchema = z . object({ email: z . string() . email(), age: z . number() . min( 18 ), }); and this form: const { register, handleSubmit, formState: { errors } } = useForm < ShippingFormInputs >({ resolver: zodResolver ( shippingFormSchema ) }); 🧠 What happens step by step 1. TypeScript ( <ShippingFormInputs> ) — BEFORE running code This only works while coding. Example mistake: register ( "emial" ); // ❌ typo 👉 TypeScript will immediately show error: "Property 'emial' does not exist" ✔ This is ONLY for developer safety. 2. Zod ( shippingFormSchema ) — WHEN user submits form Now user runs the app and enters: email: "abc" age: 10 Then user clicks submit. 👉 Now Zod runs: z . string() . email() ❌ invalid z . number() . min( 18 ) ❌ in...