Skip to content

fix: avoid BigInt literal in closeTo for runtime compat#1748

Merged
43081j merged 2 commits into
chaijs:mainfrom
bheemreddy-samsara:fix/hermes-bigint-closeTo
Nov 21, 2025
Merged

fix: avoid BigInt literal in closeTo for runtime compat#1748
43081j merged 2 commits into
chaijs:mainfrom
bheemreddy-samsara:fix/hermes-bigint-closeTo

Conversation

@bheemreddy-samsara

Copy link
Copy Markdown
Contributor

Summary

  • Avoid emitting a BigInt literal in Assertion.closeTo, which causes Hermes (React Native) to fail bundle
    evaluation with No identifiers allowed directly after numeric literal.
  • Use regular number math for abs so the code path stays compatible with engines lacking BigInt literal parsing.

Context

  • RN 0.79.x, Hermes on Android.
  • Chai 5.3.3.
  • Hermes rejects the 0n literal during bundle load; app crashes before tests run.

Change

  • lib/chai/core/assertions.js: change const abs = (x) => (x < 0n ? -x : x); to const abs = (x < 0 ? -x : x);
    and document the rationale.

Testing

  • Verified on a React Native app with Hermes: harness tests now load and pass; the prior syntax error is gone.

@bheemreddy-samsara bheemreddy-samsara requested a review from a team as a code owner November 20, 2025 16:05
@bheemreddy-samsara

Copy link
Copy Markdown
Contributor Author

@snewcomer can i get a review on this ?

@43081j 43081j merged commit 243bf86 into chaijs:main Nov 21, 2025
6 checks passed
@bheemreddy-samsara bheemreddy-samsara deleted the fix/hermes-bigint-closeTo branch November 21, 2025 23:43
@bheemreddy-samsara

bheemreddy-samsara commented Nov 21, 2025

Copy link
Copy Markdown
Contributor Author

@43081j Quick question on when will this be released ?

@43081j

43081j commented Nov 22, 2025

Copy link
Copy Markdown
Contributor

ill aim to release it in the next couple of days 👍

@bheemreddy-samsara

Copy link
Copy Markdown
Contributor Author

@43081j do you have plan for the release before the new year ?

@43081j

43081j commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

should be released in 6.2.2 👍

let me know if all is well

@bheemreddy-samsara

Copy link
Copy Markdown
Contributor Author

@43081j thanks a ton :-) Happy Holidays and Merry Christmas

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.

2 participants