ts-xor icon indicating copy to clipboard operation
ts-xor copied to clipboard

Issue with function or array

Open wawyed opened this issue 5 years ago • 3 comments

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

wawyed avatar Feb 19 '20 16:02 wawyed

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.

maninak avatar Feb 23 '20 22:02 maninak

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.

wawyed avatar Feb 24 '20 09:02 wawyed

Looks like a bug, possibly because in javascript

typeof [] // 'object'

#justJavascriptThings :man_facepalming:

I'll investigate further in the upcoming days as soon as I get the time.

maninak avatar Feb 27 '20 13:02 maninak

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.

maninak avatar Feb 10 '23 05:02 maninak