V7 Typescript issue – Type instantiation is excessively deep and possibly infinite.

Describe the bug
After upgrading the v7 rc.4, it seems there is now an issue with typescript. When I provide a form values type as a generic to useForm and call setValue with a field array, typescript will show a compile-time error of:

Type instantiation is excessively deep and possibly infinite.

This worked fine in the previous versions. Additionally, my form values type is not recursive or infinitely deep.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the sandbox
  2. Notice the typescript error

Codesandbox link (Required)
https://codesandbox.io/s/objective-flower-zwjhb?file=/src/types.ts

Expected behavior
This should not throw an error.

Additional information
I added full types as they appear in my project to replicate the bug as best as possible. I think the error is focused on the FieldsToMatch section of the Queries field array.

2 thoughts on “V7 Typescript issue – Type instantiation is excessively deep and possibly infinite.