react-hook-form: [Bug]: TypeScript errors type incorrect if value is an Object
Version Number
7.6.0
Codesandbox/Expo snack
https://codesandbox.io/s/blue-sea-fkyiq?file=/src/App.tsx:198-216
Steps to reproduce
Make a form whose type includes a value of type Big, see that the errors field types it as a DeepMap<Big, FieldError> and that you end up with the error object having a bunch of fields it shouldn’t have.
I ended up in this situation using a zod resolver with a transform to convert string number input into a Big
Expected behaviour
Since it’s a leaf it should have a value of FieldError
What browsers are you seeing the problem on?
No response
Relevant log output
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 19 (5 by maintainers)
@uncvrd @congqiao My solution for this was just to manually cast the types in the
onSubmithandler. This lets me use the latest version, even though it’d be nice if I didn’t have to cast. Here’s an example:@kotarella1110 If I’m reading your comment correctly, it seems like the code I pasted above should no longer be a problem in the latest version, but I’m still seeing it. Putting the following code into VS Code still gives me the same TS error as before:
I will try to come up with a solution for this.
I believe I may be experiencing the same issue in an upgrade from v7.14.2 to v7.15.1. I get the following TS errors on my formSubmit function when I try to pass it to
handleSubmit:In this case, I’m trying to use a luxon
DateTimeobject in the form.I will fix this
Same error on
7.27.1using a Luxon Duration. Resolved by downgrading to7.14.2.I think we’re experiencing an issue related to this. For example if we want to use
Set<string>as a type in ourFormDatathis doesn’t work in latest versions.Note that that used to work
v7.12.2.As far as I know, we don’t support custom Interface as above, @kotarella1110 is there any workaround for this usage?