Replies: 6 comments
|
Or even more specifically: As per documentation |
|
react-hook-form/src/useWatch.ts Lines 70 to 81 in 51589c5 You can hover over the function definition in VSCode too see the various overloaded definitions.
|
|
@BrendanC23 thank you for explaining. Now I understand the purpose of the overloaded definition and I see it is working correctly in VS Code. Could you explain why it is not working for the IDE? |
|
I'm not sure why you're experiencing different behavior with WebStorm. Can you post your code? Are you able to replicate the error in a CodeSandbox/StackBlitz project? Can you include a screenshot of the exact error message your IDE is giving you? |
|
A dummy example I have created in my JS project: Produces the following warning from IDE side:
And IDE navigates me to the definition of the https://codesandbox.io/p/sandbox/hopeful-fire-qf3lrn Environment: |
|
useWatch already accepts a string value at runtime, but I think the intended typing is FieldPath rather than string. useWatch({ is supported while still preserving type safety for valid field paths. Using name?: string would make the API less type-safe because arbitrary strings would be accepted even when they don't exist in TFieldValues. So unless there's a specific use case requiring dynamic/untyped field names, the current FieldPath approach seems intentional. |



Uh oh!
There was an error while loading. Please reload this page.
Hi!
Should useWatch accept
nameas a string?E.g.
name?: stringreact-hook-form/src/useWatch.ts
Line 43 in 51589c5
All reactions