maninak / ts-xor

Compose object types containing mutually exclusive keys, using this generic Typescript utility type.
https://app.radicle.at/nodes/seed.radicle.at/rad:z3nP4yT1PE3m1PxLEzr173sZtJVnT
MIT License
106 stars 5 forks source link

Issue with function xor array #19

Closed wawyed closed 1 year ago

wawyed commented 4 years ago

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

maninak commented 4 years ago

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.

wawyed commented 4 years ago

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.

maninak commented 1 year ago

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.