resolvers
resolvers copied to clipboard
issue: [zod] Using enum values as keys of an object causes a type error when trying to watch the value
Version Number
5.0.1 (zod v3.24.2, RHF v7.55.0)
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/mxfzvx
Steps to reproduce
- Create a fresh react project with zod, RHF, and @hookform/resolvers
- create a zod schema that has an object keyed by an enum (not a
Record) - set up a component that provides a
useFormreturn viaFormProvider, passing the zod schema touseFormwith thezodResolver - create a consumer component that calls
useFormContextto get access towatch - try to watch one of the fields keyed by an enum
- it will yield a type error
I'm not even sure if this is the right place to report this issue, so apologies if that is the case.
Expected behaviour
watch should not throw a type error, and should correctly infer the type of the array from the schema/zod type.
What browsers are you seeing the problem on?
Chrome
Relevant log output
N/A
Code of Conduct
- [x] I agree to follow this project's Code of Conduct