最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Angular typescript error with BigInt and Optional Chaining, nullish coalescing - Stack Overflow

programmeradmin1浏览0评论

We have an application that needs to be supported in old Chrome (v79).

Angular Version 13.2.7 Typescript Version 4.5.5 Node Version 16.14.0

We are getting an error:

ERROR: Big integer literals are not available in the configured target environment

When we set target as 2017 (anything less than 2020) & optimization is enabled for the build. BigInt are part of es2020 specification & I could not find a polyfill that works.

When we set target as es2020, error with BigInt is resolved, angular build is successful but application fails to open in Chrome 79 due to error Unrecognized character. This is happening as for es2020 optional chaining (?.) & nullish coalescing is not transpiled by typescript as these operators are natively supported in es2020 target. So we can neither stay on es2017 nor jump to es2020. I looked into using Babel transpilation with Angular, WebPack but nothing worked. Is anyone able to fix this issue?

We have an application that needs to be supported in old Chrome (v79).

Angular Version 13.2.7 Typescript Version 4.5.5 Node Version 16.14.0

We are getting an error:

ERROR: Big integer literals are not available in the configured target environment

When we set target as 2017 (anything less than 2020) & optimization is enabled for the build. BigInt are part of es2020 specification & I could not find a polyfill that works.

When we set target as es2020, error with BigInt is resolved, angular build is successful but application fails to open in Chrome 79 due to error Unrecognized character. This is happening as for es2020 optional chaining (?.) & nullish coalescing is not transpiled by typescript as these operators are natively supported in es2020 target. So we can neither stay on es2017 nor jump to es2020. I looked into using Babel transpilation with Angular, WebPack but nothing worked. Is anyone able to fix this issue?

Share Improve this question edited Jan 23 at 7:38 JSON Derulo 17.6k11 gold badges56 silver badges73 bronze badges asked Jan 23 at 7:07 Ajit HingmireAjit Hingmire 2211 silver badge10 bronze badges 1
  • @JSONDerulo we have legacy adobe flex applications that do not work Chrome 80 & later versions, last working version is Chrome 79, this browser version is wrapped in another desktop applications which users use to use our application. browserlstrc works in general targeting older version, but we are in this peculiar situation as I mentioned in the post – Ajit Hingmire Commented Jan 23 at 7:32
Add a comment  | 

2 Answers 2

Reset to default 1

You can prevent the error by adding es2020.bigint to the lib array in your tsconfig.json:

{
  "target": "es2017",
  "lib": ["es2017", "dom", "es2020.bigint"]
}

This should target ES2017, and additionally include the types just for bigint.

Try to build the app after adding this browserslint config in the package.json.

For key production add the supports bigint value in the list.

"browserslist": {
    "production": [
      "supports bigint",
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
发布评论

评论列表(0)

  1. 暂无评论