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

Error "has multiple definitions" with discriminate unions #1836

Draft
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

webjunkie
Copy link

I encounter errors with using discriminate unions in certain cases. I was able to reproduce a test case that throws Type "Animal" has multiple definitions.

Interestingly, if I modify the example and add just another type and make that the discriminate union, it works, but it would be very inconvenient in my project:

export type Fish = {
    animal_type: "fish";
    found_in: "ocean" | "river";
};

export type Bird = {
    animal_type: "bird";
    can_fly: boolean;
    likes_to_eat: EatSource;
};

export type Animal = Bird | Fish;

/**
 * @discriminator animal_type
 */
export type EatSource = Animal

@domoritz domoritz marked this pull request as draft April 7, 2024 22:57
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 this pull request may close these issues.

1 participant