Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
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 havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
exporttypeExampleUnion=boolean|number;exporttypeExampleRoot=ExampleUnion|ExampleObject;exportinterfaceExampleObject{[key:string]:ExampleRoot;}
ESLint Config
module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/<rule-name>":["error", ...<options>],},};
tsconfig
{"compilerOptions": {// ... }}
Expected Result
This interface can be either be left as-is or auto-fixed to a mapped object type:
exporttypeExampleObject={[keyinstring]:ExampleRoot;};
Actual Result
It's actually autofixed toRecord<string, ExampleRoot>
, which causes TypeScript to give complaints thatType 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 in4972ecd
// Workaround for infinite type recursion | |
exportinterfaceJSONSchema4Object{ | |
[key:string]:JSONSchema4TypeExtended; | |
} |