question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

V7: Controller ```value``` type and ```watch``` type is ```never``` when using ```watch``` inside a Field array

See original GitHub issue

Describe the bug As Shown in the sandbox, I was trying to access a value using the watch method from inside the field components. but the return type is always never. The Same type occurs in the Controller at the same component when trying to access the value. Also setting a value with setValue() is not possible due to the never type. screen2

Am I doing something wrong ?

Codesandbox link (Required) https://codesandbox.io/s/bold-meninsky-4ppxs?file=/src/App.tsx

Expected behavior watch method should return the proper type defined the the type definitions, instead returns never.

Screenshots If applicable, add screenshots to help explain your problem.

screenshot from the actual project, somehow the type here is never while in the sandbox the type is any.

screen

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
bluebill1049commented, Apr 19, 2021

Thanks, @ymor I think the next release of TS will improve on that (https://github.com/microsoft/TypeScript/pull/43361).

1reaction
ymorcommented, Apr 19, 2021

@Gencko94 You need to use something like the following for TS to get the correct type. `variationValues.${index}.priceEnabled` as `variationValues.0.priceEnabled`

I assume this is some form of typescript limitation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument of type 'string' is not assignable to parameter of type ...
I'm running into this error while trying to set a dynamic name on a Controller. Can you add a code snippet of the...
Read more >
useWatch | React Hook Form - Simple React forms validation
Performant, flexible and extensible forms with easy-to-use validation.
Read more >
newValue and oldValue parameters are the same when deep ...
Whenever I change the value of any product (i.e. controls. ... I should be able to watch my root array with deep set...
Read more >
What's new in ASP.NET Core 7.0 - Microsoft Learn
In ASP.NET Core 7.0, types in DI are checked at app startup with ... Bind query string values to a primitive type array....
Read more >
Layouts and binding expressions | Android Developers
For example: instead of List<String> you have to write List<String> . You can also refer to a value in the map using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found