OR interfaces?

What should EITHER mean?
interface ONE {
one: number;
i: string;
}
interface TWO {
two: number;
j: string;
}

type EITHER = ONE | TWO;
interface ONE {
one: number;
i: string;
}
interface TWO {
two: number;
j: string;
}

type EITHER = ONE | TWO;
EITHER seems to accept anything that has * ALL the elements of either ONE or TWO, along with * zero or more elements of the other.
4 Replies
Bubbles
Bubbles3y ago
A union type like this means that it the type is actually atleast One or Two which means that sometimes a combination of both is also allowed If you want them to be exclusive then adding the same property with a different type can help Like kind: "One" and kind: "Two"
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
dan.the.discloser
how would I say that I want it to be exactly one of the them (ie: to have exactly 2 elements in it)
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?