Closed
Description
- 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": ["error", "index-signature"]
}
}
type NavbarItems = Record<
string,
// lazy-load the component
() => (props: any) => JSX.Element
>;
type NavbarItems = Record<
Exclude<"a" | "b" | "c", "a">,
string
>;
Expected Result
I expect the first to be fixed with comment preserved, and the second to be fixed to valid code:
// lazy-load the component
type NavbarItems = { [key: string]: () => (props: any) => JSX.Element };
type NavbarItems = { [key in Exclude<"a" | "b" | "c", "a">]: string };
Actual Result
// This has the comment swallowed
type NavbarItems = { [key: string]: () => (props: any) => JSX.Element };
// This should use mapped type instead of index signature
type NavbarItems = { [key: Exclude<"a" | "b" | "c", "a">]: string };
Additional Info
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
5.16.0 |
@typescript-eslint/parser |
5.16.0 |
TypeScript |
4.6.3 |
ESLint |
8.11.0 |
node |
17.5.0 |