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.

control type incompatibility in v6.5.0-6.8.4

See original GitHub issue

Describe the bug

When specifying types for controls via T extends Record<string, any> typing errors are raised that exist from versions 6.5.0 through to 6.8.4. I’ve demonstrated the issue in sandboxes below for the error as well as the working version in 6.4.1.

Note: that it doesn’t seem to impact the execution on codesandbox, but under certain TypeScript configurations will break the build.

image

Type 'Control<T>' is not assignable to type 'Control<Record<string, any>> | undefined'.
  Type 'Control<T>' is not assignable to type 'Control<Record<string, any>>'.
    Type 'Control<T>' is not assignable to type '{ removeFieldEventListener: (field: Field, forceDelete?: boolean | undefined) => void; mode: Readonly<{ isOnBlur: boolean; isOnSubmit: boolean; isOnChange: boolean; isOnAll: boolean; isOnTouch: boolean; }>; ... 19 more ...; renderWatchedInputs: (name: string, found?: boolean | undefined) => void; }'.
      Types of property 'updateFormState' are incompatible.
        Type '(args?: Partial<FormState<T>> | undefined) => void' is not assignable to type '(args?: Partial<FormState<Record<string, any>>> | undefined) => void'.
          Types of parameters 'args' and 'args' are incompatible.
            Type 'Partial<FormState<Record<string, any>>> | undefined' is not assignable to type 'Partial<FormState<T>> | undefined'.
              Type 'Partial<FormState<Record<string, any>>>' is not assignable to type 'Partial<FormState<T>>'.
                Types of property 'dirtyFields' are incompatible.
                  Type 'DeepMap<Record<string, any>, true> | undefined' is not assignable to type 'DeepMap<T, true> | undefined'.
                    Type 'DeepMap<Record<string, any>, true>' is not assignable to type 'DeepMap<T, true>'.ts(2322)
controller.d.ts(20, 5): The expected type comes from property 'control' which is declared here on type '(IntrinsicAttributes & { as: "textarea" | "input" | "select" | FunctionComponent<any> | ComponentClass<any, any> | ReactElement<...>; render?: undefined; } & { ...; } & Pick<...>) | (IntrinsicAttributes & ... 2 more ... & Pick<...>)'

Codesandbox link (Required) Bug 6.8.4 - https://codesandbox.io/s/react-hook-form-control-type-issue-yj7kz?file=/src/TextField.tsx Working 6.4.1 - https://codesandbox.io/s/react-hook-form-control-type-issue-forked-fmpuo?file=/src/TextField.tsx

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
delessepscommented, Sep 24, 2020
1reaction
bluebill1049commented, Sep 24, 2020

sweet closing this issue, will release the patch soon 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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