Skip to content

chore(generic): add more falsy values #14320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed

Conversation

fzn0x
Copy link
Member

@fzn0x fzn0x commented Apr 4, 2022

Prevent another non-truthy values being not passed by typescript.

@fzn0x fzn0x added the type: refactor DEPRECATED: replace with the "meta" issue type label Apr 4, 2022
@fzn0x fzn0x self-assigned this Apr 4, 2022
@fzn0x fzn0x requested a review from a team April 4, 2022 20:19
@fzn0x fzn0x force-pushed the fzn0x-add-more-falsy-values branch from d12b7d6 to 2d27a27 Compare April 4, 2022 20:50
@WikiRik
Copy link
Member

WikiRik commented Apr 4, 2022

Any reason not to follow https://developer.mozilla.org/en-US/docs/Glossary/Falsy ? Apart from document.all

@fzn0x
Copy link
Member Author

fzn0x commented Apr 4, 2022

I prefer using rebase for cleaner commit details, including squash.

@fzn0x
Copy link
Member Author

fzn0x commented Apr 4, 2022

Any reason not to follow https://developer.mozilla.org/en-US/docs/Glossary/Falsy ? Apart from document.all

You can take a look at the description, it was giving some alternative values for falsy/falsey too.

I wish we can add more falsy values to prevent non-truthy values being not passed by typescript.

@fzn0x
Copy link
Member Author

fzn0x commented Apr 4, 2022

Updated the PR description for the changes goals.

@fzn0x fzn0x force-pushed the fzn0x-add-more-falsy-values branch 2 times, most recently from 2e1e373 to 66ee23c Compare April 5, 2022 22:30
@WikiRik
Copy link
Member

WikiRik commented Apr 5, 2022

Apparently there was a reason to not add NaN here; #13763 (comment)

@fzn0x
Copy link
Member Author

fzn0x commented Apr 5, 2022

Apparently there was a reason to not add NaN here; #13763 (comment)

It was actually discussed in here too microsoft/TypeScript#28682 but it was still feasible to add it yet, there is some mathematical operation are returning NaN

fzn0x added 9 commits April 6, 2022 05:45
falsy/falsey means internal toBoolean returns false for the values

0.0 | -0.0 : any zeroish number return false
0x0 | -0x0 : represent hex number of 0
NaN : Not a Number
---
**new falsy values on ES2020**
0x0n | -0x0n : the bigint of zero and negative zero, alongside 0n and -0n
---
@fzn0x fzn0x force-pushed the fzn0x-add-more-falsy-values branch from 0b69fba to 05c7d7e Compare April 5, 2022 22:45
@ephys
Copy link
Member

ephys commented Apr 6, 2022

Since there are no NaN type in TypeScript yet, I think we should not change anything. Trying to get the type of NaN will at best be number, which will match any number

@fzn0x
Copy link
Member Author

fzn0x commented Apr 6, 2022

Reference in

Closed this PR, this PR should be future notes also

@fzn0x fzn0x closed this Apr 6, 2022
@fzn0x fzn0x deleted the fzn0x-add-more-falsy-values branch April 6, 2022 14:18
@sequelize sequelize locked as resolved and limited conversation to collaborators Apr 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: refactor DEPRECATED: replace with the "meta" issue type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants