Skip to content

Bug: Types incorrectly identified as missing dependencies for eslint-plugin-react-hooks@4.1.0 with @typescript-eslint/parser@4.0.1 #19742

Closed
@ifiokjr

Description

@ifiokjr

React version: 16.13.1 (although this is related to the eslint plugin).

Steps To Reproduce

  1. Install eslint-plugin-react-hooks@4.1.0 with @typescript-eslint/parser@4.0.1 in a TypeScript project.
  2. Within your hook define a type, or cast a value to a certain type`
    const actions = useMemo(
    	() => bindActionCreators(MultishiftActions, dispatch) as Partial<Item>,
    	[dispatch],
    );
  3. eslint-plugin-react-hooks responds with this error React Hook useMemo has a missing dependency: Item. Either include it or remove the dependency array.

Link to code example: remirror/remirror/pull/619

  • Checkout the remirror codebase
     git clone https://github.com/remirror/remirror
     git checkout typedoc
  • Install the dependencies with pnpm. To setup pnpm run npm i -g pnpm.
  • Run the command pnpm run lint:es to lint the codebase.

The current behavior

Types are identified as missing dependencies within a hook and CI fails.

The expected behavior

Types shouldn't be identified as missing dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions