You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The typescript typings on this seem to be unrepresentative of the JS functionality
As far as I can tell doing
compare({a: 12},null)
would just return
false
in a pure JS env, but with TS it causes an error
Which isn't too much of an issue if you're passing null manually, but if you've got a value coming from elsewhere with a typing of:
typeSomethingThatCouldBeNull={a: number}|null
and you're trying to use the compare function it'll produce a TS error but (as far as I can tell) the JS handles it and returns false as expected - meaning you have to duplicate the null checks which already happen within compare for both values prior to calling compare.
There's been a couple of contributors contributing to it so I don't want to just raise a PR getting rid of the typings without fully understanding it, but it seems like to me if the goal with the TS typings is to accurately type the JS then this would probably be better served using either unknown or any
The text was updated successfully, but these errors were encountered:
https://github.com/angus-c/just/blob/fee2bf9/packages/collection-compare/index.d.ts
The typescript typings on this seem to be unrepresentative of the JS functionality
As far as I can tell doing
would just return
false
in a pure JS env, but with TS it causes an error
Which isn't too much of an issue if you're passing
null
manually, but if you've got a value coming from elsewhere with a typing of:and you're trying to use the
compare
function it'll produce a TS error but (as far as I can tell) the JS handles it and returnsfalse
as expected - meaning you have to duplicate the null checks which already happen withincompare
for both values prior to callingcompare
.There's been a couple of contributors contributing to it so I don't want to just raise a PR getting rid of the typings without fully understanding it, but it seems like to me if the goal with the TS typings is to accurately type the JS then this would probably be better served using either
unknown
orany
The text was updated successfully, but these errors were encountered: