ts-json-schema-generator
ts-json-schema-generator copied to clipboard
Error "has multiple definitions" with discriminate unions
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