Skip to content
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

fix: make isFalsyType() return true for 0n #545

Merged

Conversation

kirkwaiblinger
Copy link
Collaborator

@kirkwaiblinger kirkwaiblinger commented Oct 27, 2024

PR Checklist

Overview

The type.value returns a PseudoBigInt object rather than an actual bigint for TS legacy support reasons. Therefore, to determine if a literal is a falsy value, we cannot rely on the truthiness of type.value alone, and need to check what the actual object is if it's not a primitive.

@kirkwaiblinger kirkwaiblinger marked this pull request as ready for review October 27, 2024 21:57
Copy link
Owner

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests are failing, could you fix those up please?

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Oct 29, 2024
@RebeccaStevens
Copy link
Collaborator

Looks like the issue is caused by an update to pnpm, to a version not compatible with the version of node we're using for the testing. #531 should fix this.

@kirkwaiblinger
Copy link
Collaborator Author

Looks like the issue is caused by an update to pnpm, to a version not compatible with the version of node we're using for the testing. #531 should fix this.

I'm thinking it's best if I just wait with this PR until that gets merged then?

@JoshuaKGoldberg
Copy link
Owner

Oh, I was looking at TypeScript 4.9.5 on https://github.com/JoshuaKGoldberg/ts-api-utils/actions/runs/11544117529/job/32131517301?pr=545:

 FAIL  src/types/utilities.test.ts > isFalsyType > returns true when given 0n
 FAIL  src/types/utilities.test.ts > isFalsyType > returns true when given -0n
AssertionError: expected false to be true // Object.is equality

#531 will drop support for TS <4.8, but I reproduce this issue on TS 4.8 and 4.9 locally.

@kirkwaiblinger
Copy link
Collaborator Author

i'll take a look then! 👍

@github-actions github-actions bot removed the status: waiting for author Needs an action taken by the original poster label Oct 30, 2024
@JoshuaKGoldberg JoshuaKGoldberg merged commit fe52a60 into JoshuaKGoldberg:main Oct 30, 2024
12 of 21 checks passed
@JoshuaKGoldberg
Copy link
Owner

@all-contributors please add @kirkwaiblinger for code.

🤖 Beep boop! This comment was added automatically by all-contributors-auto-action.
Not all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed.
...and of course, thank you for contributing! 💙

Copy link
Contributor

@JoshuaKGoldberg

I've put up a pull request to add @kirkwaiblinger! 🎉

@kirkwaiblinger kirkwaiblinger deleted the pseudobigint-aint-bigint branch October 30, 2024 18:02
JoshuaKGoldberg pushed a commit that referenced this pull request Oct 30, 2024
Adds @kirkwaiblinger as a contributor for code.

This was requested by JoshuaKGoldberg [in this
comment](#545 (comment))

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Bug: isFalsyType should return true for 0n
3 participants