maninak / ts-xor

Compose object types containing mutually exclusive keys, using this generic Typescript utility type.

Home Page:https://app.radicle.at/nodes/seed.radicle.at/rad:z3nP4yT1PE3m1PxLEzr173sZtJVnT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with function xor array

wawyed opened this issue · comments

For some reason comparing a function vs an array fails :(
Playground Link

Hey, thanks for filing an issue.

Could you please elaborate on what is the expected and actual behaviour? I'm having a hard time understanding what "comparing a function vs an array fails" means.

Hi, sorry the link didn't work. I've updated it and it should be more clear what the problem is. Let me know if you want me to clarify further.

There should never be a specific need to have exclusively a function or exclusively an array, since those are always mutually exclusive by default.

As a counter-example, try to assign both a function and an array to a variable (the way that your playground link shows). It's not something that is possible in JavaScript.

In such a use case the union operator (|) is what one should use.

Hence, I don't see this as a bug. If I'm missing something, please let me know.