issue: useForm and useFormContext without FieldValues gives formState.errors object with any instead of FieldError
#8518
Version Number7.32.1 Codesandbox/Expo snackhttps://codesandbox.io/s/error-type-issue-with-react-hook-form-ku968b Steps to reproduce
Notice that you're getting warnings about unsafe Expected behaviourExpected the type to be the same as it normally is, except for keys to be unknown: const errors: {
[x: string]: FieldError | undefined;
}But instead it ends up as the following, which gives warnings from Typescript and no type-help or type-safety from editor: const errors: {
[x: string]: any;
}If I pass a type for the values, then it becomes for example: const errors: {
firstName?: FieldError | undefined;
}I expected the same object shape without a type for the values What browsers are you seeing the problem on?Edge Relevant log outputNo response Code of Conduct
|
Replies: 1 comment 1 reply
|
It's a current limitation with V7, fixed in the next major version: https://codesandbox.io/s/error-type-issue-with-react-hook-form-forked-otu0nb?file=/src/App.tsx however currently it's blocked by TS 4.7 update at the V8 branch. |
It's a current limitation with V7, fixed in the next major version: https://codesandbox.io/s/error-type-issue-with-react-hook-form-forked-otu0nb?file=/src/App.tsx however currently it's blocked by TS 4.7 update at the V8 branch.