Type NestedValue + yupResolver fails type checking after v1.3.7
See original GitHub issueDescribe the bug
When I try to type useForm
with property that is an array of strings, like:
import * as yup from 'yup'
import { NestedValue } from 'react-hook-form'
interface ApplicationCreationFormValidation {
scopes: NestedValue<string[]>
}
const schema = yup
.object({
scopes: yup.array().of(yup.string()).required('You must select at least one scope')
})
.required()
const form = useForm<ApplicationCreationFormValidation>({
defaultValues: { scopes: [] },
mode: 'onTouched',
resolver: yupResolver(schema)
})
I get de following type error:

To Reproduce To reproduce you can go to the codesandbox that @bluebill1049 posted on an issue related to it:
If you bump the version to the latest it crashes.
Codesandbox link (Required) https://codesandbox.io/s/infallible-panini-7duc6?file=/src/App.tsx
Expected behavior it shouldn’t have any type error
Desktop (please complete the following information):
- OS: macOS Big Sur
- Browser Chrome
- Version 95.0.4638.69 (Official Build) (arm64)
Additional context I’ve noticed that stopped working after v1.3.7. In my case, if I downgrade the version to 1.3.7, it works.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
reactjs - react-hook-form v7 `resolver` type error when using ...
I have an interface for the form like this: interface FormData { name: string; age: number | ""; hobbies: string[]; }.
Read more >@hookform/resolvers - npm
React Hook Form validation resolvers: Yup, Joi, Superstruct, Zod, Vest, Class Validator, io-ts, Nope, computed-types and Typanion.
Read more >Advanced Usage - React Hook Form
Step 3: Write tests. The following criteria are what we try to cover with the tests: Test submission failure. We are using waitFor...
Read more >react-hook-form | Yarn - Package Manager
... developers to convert error messages to String to pass the type check ... Deprecate NestedValue and UnpackNestedValue type, will be removed in...
Read more >Type NestedValue + yupResolver fails type checking after v1.3.7
Starting at version 2 of resolvers, you've to use the v7 version of react-hook-form.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bluebill1049 hmm this doesn’t seem like a version issue? I’m getting the same thing on
react-hook-form@7.27.1
with@hookform/resolvers@2.8.8
.I’m using Zod. My workaround is likely going to be the same as @jonatassales, but not ideal.
Traced down react-hook-form/react-hook-form#7888 and it’s fixed in v8! So looks like this was technically a version issue after all. 😜