Bug: [consistent-indexed-object-style] Interface with recursive index signature autofixed to Record instead of mapped type #7863
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.2.2&fileType=.ts&code=KYDwDg9gTgLgBDAnmYcCiICGBbMAbYAVQDsBLCYuAXjgCMIIDNKAfOYgV21uCgG4AUANCRYCZKgw58wAEoN4NKbgIlyrdFhXAA8rQBWwAMYxBw8NHiliMXgDNMRyVpl7DJuAG8BcOAG0Aa2BEAC44AGcYKGsAcwBdMOUZeQhTAQBfASA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6MgeyeUuX0Ra1mAE0QAPRMNocARgCtEZOn0JJ0URNGgdokcGAC%2BIA0A&tsconfig=&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
This interface can be either be left as-is or auto-fixed to a mapped object type:
Actual Result
It's actually autofixed to
Record<string, ExampleRoot>
, which causes TypeScript to give complaints thatType alias '(Example(Root|Object)' circularly references itself.
https://typescript-eslint.io/play/#ts=5.2.2&fileType=.ts&code=KYDwDg9gTgLgBDAnmYcCiICGBbMAbYAVQDsBLCYuAXjgCMIIDNKAfOYgV21uCgG4AUANCRYCZKgw58wAEoN4NKbgIlyrdFhXAA8rQBWwAMYxBw8NHhIUm6QT2GT1OLOPQAJgB4AzjCiliAHMAGltteQgYAD5BIA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6MgeyeUuX0Ra1mAE0QAPRMNocARgCtEZOn0JJ0URNGgdokcGAC%2BIA0A&tsconfig=&tokens=false
Additional Info
I suspect this is in the same area as #4730 and #6598 but not quite the same.
Found while trying to enable the rule on typescript-eslint:
typescript-eslint/packages/utils/src/json-schema.ts
Lines 35 to 38 in 4972ecd
The text was updated successfully, but these errors were encountered: