facebook / facebook/hermes

Intl.NumberFormat.format() throws "Cannot convert BigInt to number" when passed a bigint on Android

Open
#1,928 3 comments 1 reaction 2 assignees Claimed by @tmikov View on GitHub
bug
Dominant language
JavaScript
Stars
11.3k
Forks
859
Avg merge
1h 30m
Merged PRs (30d)
3

Description

## Bug Description

`Intl.NumberFormat.prototype.format()` throws `TypeError: Cannot convert BigInt to number` when passed a `bigint` argument on Android. The same code works correctly in V8 (Chrome) and SpiderMonkey (Firefox).

- [x] I have run `gradle clean` and confirmed this bug does not occur with JSC
- [x] The issue is reproducible with the latest version of React Native.

Hermes git revision (if applicable): bundled with React Native 0.81.5
React Native version: 0.81.5
OS: Android
Platform: arm64-v8a

## Steps To Reproduce

1. Create a React Native app with Hermes enabled (default for RN 0.81.5)
2. Run on an Android device or emulator
3. Execute any of the following:

```javascript
// All three crash with: TypeError: Cannot convert BigInt to number
new Intl.NumberFormat().format(BigInt('2'))
new Intl.NumberFormat('en-US').format(BigInt('2'))
new Intl.NumberFormat().format(2n)
```

The crash occurs regardless of whether the `bigint` is created via the `BigInt()` constructor or a bigint literal (`2n`), and regardless of whether a locale argument is provided.

**Workaround:**

```javascript
new Intl.NumberFormat().format(Number(BigInt('2'))) // ✅ returns "2"
```

## The Expected Behavior

All three expressions should return `"2"` without throwing, as `bigint` is a valid argument per [ECMA-402](https://tc39.es/ecma402/#sec-intl.numberformat.prototype.format) and works correctly on V8 and SpiderMonkey.

**Related open issues:**
- #1317 — `Intl.NumberFormat` `signDisplay` can't always display sign
- #789 — `Intl.NumberFormat` `signDisplay: 'always'` truncates currency sign on Android

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.