You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Treatment of recursive tuples that utilize type spread. #40229
I'm running into this, and I have a nice minimal example that shows a case that seems easy to think about:
type A = [A]; // OK
type B = [...[B]]; // Type alias 'B' circularly references itself.
Obviously this example isn't a sensible thing to write in real code, but I think it clearly demonstrates the issue with the spread operator causing the typechecker to somehow "forget" that the recursion is actually fine.
For reference, my actual use case type looks something like:
type ImapStruct = [ImapStructDetailsLeaf] | [ImapStructDetailsMultipart, ...Array<ImapStruct>];
// Type alias 'ImapStruct' circularly references itself.
I'm trying to type something that I get from the node-imap library; in the library's type stubs it looks like they just spell it any[].
Activity
harrysolovay commentedon Aug 25, 2020
Another important capability is genericizing the "
Nested" type, such that the following would also be valid:RyanCavanaugh commentedon Aug 25, 2020
Anders Hejlsberg (@ahejlsberg) any recommendations?
gwillen commentedon Jul 23, 2023
I'm running into this, and I have a nice minimal example that shows a case that seems easy to think about:
Obviously this example isn't a sensible thing to write in real code, but I think it clearly demonstrates the issue with the spread operator causing the typechecker to somehow "forget" that the recursion is actually fine.
For reference, my actual use case type looks something like:
I'm trying to type something that I get from the node-imap library; in the library's type stubs it looks like they just spell it
any[].