Closed hejtmii closed 1 year ago
I found out that the function nullthrows checks only for null
That's not correct, the function does a != null
check which means that null
and undefined
are both considered not equal to null
. If the function instead used !== null
then you would be correct.
i just double-checked in the JS console in Chrome to be sure:
null != null false undefined != null false 0 != null true
I suspect the problem is somewhere else.
Hi, while debugging DraftJS, I found out that the function
nullthrows
checks only fornull
, but its error message says "Got unexpected null or undefined"Also, the way its result is typed seems wrong, because
undefined
passes the condition returningundefined
where non-nullableT
should be ...I would expect it to either check also for
undefined
, or returnT | undefined
and not returnundefined
in the error message ...https://github.com/facebook/fbjs/blob/d8f0f430a689ee1e5bb070d501155fa29e329019/packages/fbjs/src/utils/nullthrows.js#L15