score:2

Accepted answer

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.

score:-1

try using const thebiggestint = bigint(9007199254740991); instead. i found out about this here: https://github.com/facebook/create-react-app/issues/6907

the 9007199254740991n syntax is very new and isn't supported by create-react-app yet.

edit: as pointed out in the comments below this answer bigint(9007199254740991) is just alternative syntax for 9007199254740991n so this will not help you. see https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/bigint for more details.

perhaps try using https://www.npmjs.com/package/big-integer instead. it uses bigint when it is available in a browser and when it isn't it acts as a polyfill.

score:4

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.


Related Query

More Query from same tag