react-hook-form: [TypeScript] ErrorMessage Component accept no props any more in version 4.8.0

Describe the bug after I updated to v4.8.0 I got this error message from Typescript on the className and name props

Type 'string' is not assignable to type 'never'.ts(2322)
Screenshot 2020-02-02 at 22 54 16

also errors prop got this following error

Type 'NestDataObject<Record<string, any>>' is not assignable to type 'never'.ts(2322)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I’m busy today, so I wil look it tomorrow.

This has not been resolved yet. Passing the name and errors prop shouldn’t cause type error.

<ErrorMessage name={name} errors={errors} /> // no type error

I will wait for @omarkhatibco to provide codesandbox.

wow type is great! great job @kotarella1110

@kotarella1110 thanks it works !

The problem is as prop is not mentioned in the documentation.

@omarkhatibco Causes this type error when strict is disabled(false) in Compiler Option(tsconfig.json). You can avoid this type error by enabling strict or strictNullChecks. I will fix this soon because of a problem with the type definition.

@bluebill1049 the type error is correct! because we can’t have className as a prop on React.Fragment. we can pass the className prop only when we pass the as prop.

<React.Fragment className="test" /> // Warning: Invalid prop `className` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.

@omarkhatibco plz provide codesandbox example.

@kotarella1110 type of name is never when as is missing

Screenshot 2020-02-03 at 10 01 51