To enable the BigInt in React as of now you have to add this comment to your code:
/* global BigInt */
Please, refer to this.
Answer from mdmundo on Stack OverflowTo enable the BigInt in React as of now you have to add this comment to your code:
/* global BigInt */
Please, refer to this.
For resolve this problem you can send on the front-end string instead of number. Native js not support big number. If you want work on front-end with big number, you can use bignumber js library: https://github.com/MikeMcl/bignumber.js/
In your case:
1. send string on front-end.
2. get number as string and create BigNumber('9223372036854775800')
ReferenceError: Can't find variable: BigInt
Bug: React 19 Uncaught TypeError: Do not know how to serialize a BigInt
Big Int error in React production build?
Can't find variable: BigInt in expo (React native)
» npm install big-integer
BigInt is enabled in node_modules/typescript/lib/lib.es2020.bigint.d.ts, so it is part of es2020 not part of esnext.
However, it seems that the ***n lexical expression is not part of lib.es2020.bigint.d.ts. Indeed, that is enabled by esnext.
To enable typescript use with BigInt but without ****n lexical expressions, this configuration worked:
{
"compilerOptions": {
"lib": [
"es2020"
],
"module": "commonjs",
"target": "es2020",
}
Adding "esnext" to the libs:
{
"compilerOptions": {
"lib": [
"es2020", "esnext"
],
"module": "commonjs",
"target": "es2020",
}
then enables(*) the ability to '****n' lexical expressions.
(*) Another separate issue is that VSCode (if you are working with that) will sometimes opaquely enable '****n' as a valid expression, even when 'esnext' is never explicitly mentioned in the relevant tsconfig.json file. Perhaps it is enabling esnext implicitly? That behavior is actually not helpful when trying to figure exactly what settings enable the ***n lexical expressions - after adding esnext to a tsconfig file and then removing it, the abilty to use ****n expressions continued anyway.
As pointed out in a comment, Bigint is a new feature.You cannot use BigInt while you have the target property in tsconfig.json in a value other than ESNext.But you shouldn’t do this because there is little browser support developer.mozilla.org and caniuse.com.