Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken unions with recursive types #55

Closed
millsp opened this issue Sep 27, 2019 · 1 comment
Closed

Broken unions with recursive types #55

millsp opened this issue Sep 27, 2019 · 1 comment
Labels
question More info is requested wiki It's nice to learn stuff

Comments

@millsp
Copy link
Owner

millsp commented Sep 27, 2019

馃 Question

Describe your question

Union types tend to malfunction when used with recursive types for reasons that are internal to TypeScript and this library. But you can make it work, just distribute your union as needed:

Union extends unknown // let's say `Union` is your union
? RecursiveType<Union> // it gets distributed to another type
: never

...And if this still doesn't work, then it's probably because the recursive type needs to do this deeply. In that case, you're welcome to open an issue, and I'll bring a Up version of that type out.

Search tags, topics

#broken #union #recursive

@millsp millsp added question More info is requested wiki It's nice to learn stuff labels Sep 27, 2019
@millsp millsp closed this as completed Sep 27, 2019
@millsp millsp pinned this issue Sep 27, 2019
@millsp millsp unpinned this issue Sep 27, 2019
@millsp millsp changed the title Distribute unions for recursive types Broken unions with recursive types Sep 27, 2019
@millsp
Copy link
Owner Author

millsp commented Dec 30, 2019

Type distribution is now a default. So you don't have to worry about your unions anymore. I recommend that you remove any extends unknown in favor of the utility only (to avoid unnecessary load).

cc @Andarist @ctrlplusb

Repository owner locked and limited conversation to collaborators Feb 2, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question More info is requested wiki It's nice to learn stuff
Projects
None yet
Development

No branches or pull requests

1 participant