Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[consistent-indexed-object-style] invalid autofix with genericsΒ #2712

@nstepien

Description

@nstepien
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/consistent-indexed-object-style": 1
  }
}
interface A<B> {
  [key: string]: B;
}

Expected Result

The interface cannot be changed into Record<string, B>, as B then becomes undefined.

Actual Result

It becomes autofixed like this:

type A = Record<string, B>;

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 4.5.0
@typescript-eslint/parser 4.5.0
TypeScript 4.0.3
ESLint 7.12.0
node 15.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomerspackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions