Skip to content

Bug: eslint-plugin-react-hooks@7.0.0 Type 'ReactHooksFlatConfig | undefined' is not assignable to type 'InfiniteArray<ConfigWithExtends>' #34788

@ulrichstark

Description

@ulrichstark

The recommended way to configure for flat config in eslint-plugin-react-hooks@7.0.0 isn't correctly typed with TypeScript and enabled noUncheckedIndexedAccess flag:

import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  reactHooks.configs.flat.recommended,
]);

Either disabling noUncheckedIndexedAccess or non-null asserting the value with ! works.

Steps To Reproduce

  1. Clone https://github.com/ulrichstark/eslint-plugin-react-hooks-type-repro
  2. Run npm install
  3. Run npx tsc

The current behavior

eslint.config.ts:4:30 - error TS2322: Type 'ReactHooksFlatConfig | undefined' is not assignable to type 'InfiniteArray<ConfigWithExtends>'.
  Type 'undefined' is not assignable to type 'InfiniteArray<ConfigWithExtends>'.

4 export default defineConfig([reactHooks.configs.flat.recommended]);
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in eslint.config.ts:4

The expected behavior

No TypeScript error.

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