H
H
Herberito Galustyan2019-08-19 20:08:09
JavaScript
Herberito Galustyan, 2019-08-19 20:08:09

BigInt literals not available when targeting lower than ESNext?

I am installing react and typescript using yarn. Create a react app my-app --typescript.
Then I wrote this code.

import React from 'react';

const App: React.FC = () => {
  const theBiggestInt = 9007199254740991n;
  return (
    <div>
   {"Durkurian"}
    </div>
  );
}

export default App;

and got the error BigInt literals are not available when targeting lower than ESNext.
What is the problem? How to fix it?
package.json
{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@types/jest": "24.0.17",
    "@types/node": "12.7.2",
    "@types/react": "16.9.2",
    "@types/react-dom": "16.8.5",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-scripts": "3.1.1",
    "typescript": "3.5.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-08-19
@Herberto

You cannot use BigInt unless you have the target property in tsconfig.json in compilerOptions set to something other than ESNext. But you should not do this, since Safari, IE and Edge do not know anything about BigInt.
BigInt. Can-i-use browser compatibility

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question