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

Is this a bug?

aweiu opened this issue · comments

i wouldn't call it so

it is due to the strictNullCheck flag
while Option is defined, Array<Option> can still be undefined
(it has been an explicit choice to behave this way, it has to do with index signature performance and legacy compatibility if I remember, you can search about this matter online. there's something here.

if (option.children) on line 13 is both a type guard AND an explicit null check on children
if (option.path) on line 16 instead acts only as type guard, but doesn't check children

in these cases i normally add a fallback on empty array

@aweiu in the couple of times I sat to invest time looking into this issue, I haven't come up with an answer for you yet (sorry!).

But I saw you just closed the issue yourself, so if you've resolved the issue some how, I'd love it if you shared your findings with all of us. :)

@aweiu in the couple of times I sat to invest time looking into this issue, I haven't come up with an answer for you yet (sorry!).

But I saw you just closed the issue yourself, so if you've resolved the issue some how, I'd love it if you shared your findings with all of us. :)

#18 (comment), In this comment, I have described the cause of the problem:
image

I understand. I'm aware of this line in the code you've shared above.

Perhaps I wasn't clear. My question was: why did you close the issue? If you think this issue is resolved I'd love it if you shared your thoughts (or even make an PR). If this problem is still not resolved, I'd prefer to have the issue remain open for visibility.

Because this issue is caused by improper use of typescript type, not because of your library. So I close it.