Skip to content
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

Record type fail with circular reference error #35164

Closed
idoros opened this issue Nov 18, 2019 · 1 comment · May be fixed by #57293
Closed

Record type fail with circular reference error #35164

idoros opened this issue Nov 18, 2019 · 1 comment · May be fixed by #57293

Comments

@idoros
Copy link

idoros commented Nov 18, 2019

TypeScript Version: 3.7.2 (and also nightly)

Search Terms: circularly references itself, Record circular reference

Code

type RecursiveTypeA = Record<number, RecursiveTypeA> // error: Type alias 'RecursiveTypeA' circularly references itself.

type RecursiveTypeB = RecursiveTypeB[] // works fine

type RecursiveTypeC = { [index: number]: RecursiveTypeC } // works fine

Expected behavior:
Record type should work like the third example that defines an object with number keys to the recursive value (the key type is irrelevant).

Actual behavior:
Only the Record type fail with circular reference

Playground Link: link

Related Issues: couldn't find any specific related issues

@idoros
Copy link
Author

idoros commented Nov 18, 2019

Reading the original PR that introduced recursive type, I can see that this has already been discussed and is by design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant