setValue()'s first parameter is always of type 'never' in Typescript
See original GitHub issueDescribe the bug I try to use react-hook-form in Typescript. The IDE (IntelliJ in my case but also the Typescript compiler) complains that
Argument of type "..." is not assignable to parameter of type never
To Reproduce
Here’s a simple codesandbox project. Open it in the Editor, wait a bit and you will see that in line index.tsx:8 “someField” will be marked red and mouse over will show
Argument of type "someField" is not assignable to parameter of type never
https://codesandbox.io/embed/react-typescript-vf3xc
The same thing happens in IntelliJ as well.
If you mouse over on useForm in index.tsx:6 the second type argument there will also be ‘never’.
Issue Analytics
- State:
- Created 4 years ago
- Comments:24 (15 by maintainers)
Top Results From Across the Web
How to set the correct typescript type for setValue in react- ...
I want to pass the function setValue() ...
Read more >Argument of type not assignable to parameter type 'never'
This type represents an array that will never contain any elements (will always be empty). To solve the error, explicitly type the empty...
Read more >Documentation - TypeScript 2.0
TypeScript has two special types, Null and Undefined, that have the values ... Because never is a subtype of every type, it is...
Read more >TypeScript Data Type - Never
TypeScript introduced a new type never , which indicates the values that will never occur. The never type is used when you are...
Read more >What is not assignable to parameter of type never error in ...
[ts] Argument of type 'string' is not assignable to parameter of type 'never'. What exactly am I doing wrong? typescript · error. May...
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
@beepsoft Your codesandbox is giving errors about crossorigin errors. However, if you pass the generic to
useForm
it should not give you any errors. In your case,useForm<{ someField: string }>()
should get rid of the error. It shouldn’t require the generic so I can look into that if you can provide a codesandbox that doesn’t trigger cors errors.@bluebill1049 Yeah, we shouldn’t require passing a generic. I think if I improve the typing to where the key extends string it should be fine. Will look into it.