Closed ericlathrop closed 3 years ago
:laughing: #thanksjavascript
I'm pretty sure -1
is truthy in most programming languages, not just Javascript.
Fascinating, I'd never done a deep dive on that one. I'm primarily java which forces true/false at the code level, but I use quite a few other languages which do appear to be "0 is false, anything non-zero is true".
This is a great illustration of why I use typescript anyway (and java mostly) ;-) - the assignment would not be valid even if technically -1 is still truthy - which should help keep code (and related docs) easier to reason about
Interesting, let's update the docs. i think it will be clearer anyway to say > 0.
typescript docs have been updated, will be reflected in 1.2.1 and in the docs.
Several places in the docs say
value is truthy if
... but one of the enum values that should be falsy is actually-1
, which is truthy. The documentation should readvalue is > 0
instead.Examples:
https://github.com/notifee/react-native-notifee/blob/f432f5fecde1400e6ebbc2e81a0fb5c298c5213e/src/types/NotificationIOS.ts#L227-L237
https://github.com/notifee/react-native-notifee/blob/f432f5fecde1400e6ebbc2e81a0fb5c298c5213e/src/types/NotificationIOS.ts#L259-L269
https://github.com/notifee/react-native-notifee/blob/f432f5fecde1400e6ebbc2e81a0fb5c298c5213e/src/types/NotificationIOS.ts#L290-L300