resolvers: yupResolver raise Types of parameters 'options' and 'options' are incompatible at react-hook-form 7.15.0
Hello.
Describe the bug
I updated react-hook-form 7.15.0, yupResolver raise following type error messages.
Type '<TFieldValues extends Record<string, any>, TContext>(values: UnpackNestedValue<TFieldValues>, context: TContext | undefined, options: ResolverOptions<TFieldValues>) => Promise<...>' is not assignable to type 'Resolver<FormType, object>'.
Types of parameters 'options' and 'options' are incompatible.
Same code with react-hook-form 7.14.2 works fine(no type error).
versions
- react: 17.0.2
- react-hook-form: 7.15.0
- @hookform/resolvers: 2.8.0
- dayjs: 1.10.6
- yup: 0.32.9
- typescript: 4.3.5
To Reproduce
- Go to https://codesandbox.io/s/sad-wilson-rvpvv?file=/src/App.tsx
- move mouse cursor to line 22 and hover
resolver
- Error message popup.
Codesandbox link (Required)
https://codesandbox.io/s/sad-wilson-rvpvv?file=/src/App.tsx:456-464
Expected behavior
No type error raised, or I want to know how to avoid type error (react-hook-form 7.14.2 works fine)
Screenshots
Desktop (please complete the following information):
- OS: macOS
- Browser Chrome
- Version 92.0.4515.159(Official Build) (x86_64)
Additional context
None
Thank you!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 24 (9 by maintainers)
Hi, My current setup is:
“@hookform/resolvers”: “^2.8.1”, “react-hook-form”: “7.15.4”, “yup”: “^0.32.9”, “@types/yup”: “^0.29.13”
They are the latest versions that are atm available and how I solved the above error is by using the yupResolver with the next generic type yupResolver<yup.AnyObjectSchema>. An example could be the following:
You can also add the defaultValues and I would recommend you to do that.
Hope it helps you 😃
7.16.0 solve the original issue above. the other issue is related to 2.8.1 https://github.com/react-hook-form/resolvers/issues/245
hello there. I ran into the same type error with
@hookform/resolvers: 2.8.1
. My setup and error is below.@jorisre Thank you for fixing, but unfortunately still raise type error in my app…
https://codesandbox.io/s/hardcore-darwin-qusu6?file=/src/App.tsx
I Updated to @hookform 2.8.1 and react-hook-form 7.15.3
@asalahjawava Does your application works fine?
@heavenshell You can remove
<FormType>
from theuseForm<FormType>
. Types are inferred from the schema.