Closed
Description
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
Repro Code
export type ExampleUnion = boolean | number;
export type ExampleRoot = ExampleUnion | ExampleObject;
export interface ExampleObject {
[key: string]: ExampleRoot;
}
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/<rule-name>": ["error", ...<options>],
},
};
tsconfig
Expected Result
This interface can be either be left as-is or auto-fixed to a mapped object type:
export type ExampleObject = {
[key in string]: ExampleRoot;
};
Actual Result
It's actually autofixed to Record<string, ExampleRoot>
, which causes TypeScript to give complaints that Type alias '(Example(Root|Object)' circularly references itself.
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