Skip to content

Bug: [consistent-indexed-object-style] type with recursive index signature autofixed to Record instead of mapped type #11121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
TastyPi opened this issue Apr 30, 2025 · 1 comment · May be fixed by #11177
Open
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@TastyPi
Copy link

TastyPi commented Apr 30, 2025

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.8.3&fileType=.tsx&code=KYDwDg9gTgLgBDAnmYcAyEDmA1AhgGwFdgBnAHgGk5QZgA7AExLhJigEs7M4BeOO4ADdgUAHy84AbwBQcOAG0A1nE5wKAXQBc6LHiLAA3NIC%2BR6aEiwEyVBhwFiE1hy5wAPv0IBbAEYj3cD4QEPjAuHQBdnrEzB5RDsDy6mZAA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6MgeyeUuX0Ra1mAE0QAPRMNocARgCtEZOn0JJ0URNGgdokcGAC%2BIA0A&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

export type Foos<K extends string = never> = {
  [k in K]: Foo;
};

export type Foo = Foos;

ESLint Config

{
  "rules": {
    "@typescript-eslint/consistent-indexed-object-style": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

It does not suggest changing Foos to be defined using Record due to the circular dependency. Same as #7863

Actual Result

It suggests changing Foos to be defined using Record, which causes an error due to the circular reference

Additional Info

No response

@TastyPi TastyPi added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 30, 2025
@kirkwaiblinger kirkwaiblinger changed the title Bug: [consistent-indexed-object-style] Interface with recursive index signature autofixed to Record instead of mapped type Bug: [consistent-indexed-object-style] type with recursive index signature autofixed to Record instead of mapped type May 1, 2025
@JoshuaKGoldberg
Copy link
Member

Heh, this is kind of the inverse of #2687 and #7863 in a way. #9068 is also kind of related.

This feels like a straightforward bug to me: that the same kind of logic added in #10537 should also be added for aliased mapped types. Thoughts @typescript-eslint/triage-team?

@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
3 participants