invertase / react-native-notifee

Moved to https://github.com/invertase/notifee
https://invertase.io/blog/open-sourcing-notifee
Other
466 stars 31 forks source link

Documentation error: -1 is truthy. #271

Closed ericlathrop closed 3 years ago

ericlathrop commented 3 years ago

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 read value is > 0 instead.

$ node
Welcome to Node.js v14.6.0.
Type ".help" for more information.
> if (-1) {
... console.log("truthy");
... }
truthy

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

mikehardy commented 3 years ago

:laughing: #thanksjavascript

ericlathrop commented 3 years ago

I'm pretty sure -1 is truthy in most programming languages, not just Javascript.

mikehardy commented 3 years ago

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

https://www.typescriptlang.org/play?#code/MYewdgzgLgBFBOBXKALAngSTAKQIYDdcJh4BLAB1gF4YBaARgG4AoUgMxgAoFl0s9CxMpQCUMAN7MY0mKEggANgFMAdApABzTgHIAEkrQAaOvRikIcJKjTaRLAL4wlCiEolSZciItXqt2hjMLMBBYHmsVWwdmZmUwqz4wABU0ciUhCigALhgAIxAfXDAYGh4lFnDElLSMyhKTRiA

helenaford commented 3 years ago

Interesting, let's update the docs. i think it will be clearer anyway to say > 0.

helenaford commented 3 years ago

typescript docs have been updated, will be reflected in 1.2.1 and in the docs.