Skip to content

issue: useController causing type error from 7.63.0 -> 7.64.0 #13081

@sheuertz

Description

@sheuertz

Version Number

7.64.0

Codesandbox/Expo snack

https://codesandbox.io/p/devbox/lucid-frost-gnfyfx

Steps to reproduce

  1. Run tsc
  2. Receive error:
app/components/tree/tree.tsx:37:37 - error TS2322: Type 'string' is not assignable to type 'never'.

37   const { field } = useController({ name, defaultValue: [] });
                                       ~~~~

  node_modules/react-hook-form/dist/types/controller.d.ts:20:5
    20     name: TName;
           ~~~~
    The expected type comes from property 'name' which is declared here on type 'UseControllerProps<never[], never, never[]>'

app/components/tree/tree.tsx:37:43 - error TS2322: Type 'never[]' is not assignable to type 'undefined'.

37   const { field } = useController({ name, defaultValue: [] });
                                             ~~~~~~~~~~~~

  node_modules/react-hook-form/dist/types/controller.d.ts:23:5
    23     defaultValue?: FieldPathValue<TFieldValues, TName>;
           ~~~~~~~~~~~~
    The expected type comes from property 'defaultValue' which is declared here on type 'UseControllerProps<never[], never, never[]>'

app/components/tree/tree.tsx:46:26 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.

46       if (value.includes(itemId)) {
                            ~~~~~~

app/components/tree/tree.tsx:47:9 - error TS2322: Type 'string[]' is not assignable to type 'never[]'.
  Type 'string' is not assignable to type 'never'.

47         value = without(value, itemId);
           ~~~~~

app/components/tree/tree.tsx:49:20 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.

49         value.push(itemId);

Expected behaviour

Expect no type errors on minor upgrade.

What browsers are you seeing the problem on?

No response

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions