gpt4 book ai didi

angular - 升级到 Angular 8 : Changing the target to "es2015" in tsconfig. json 导致 polyfills-2015 出错

转载 作者:行者123 更新时间:2023-12-04 01:43:28 24 4
gpt4 key购买 nike

将目标更改为 时es2015 (而不是 es5),我在启动我的应用程序时收到以下错误:

polyfills-es2015.4a168e5d0734802f67ed.js:1 Uncaught TypeError: Cannot set property 'true' of undefined
at Object.6dTf (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at Module.hN/g (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at Object.1 (polyfills-es2015.4a168e5d0734802f67ed.js:1)
at u (runtime-es2015.05393c8efcd0eb158773.js:1)
at t (runtime-es2015.05393c8efcd0eb158773.js:1)
at Array.r [as push] (runtime-es2015.05393c8efcd0eb158773.js:1)
at polyfills-es2015.4a168e5d0734802f67ed.js:1

另外,我需要 在我的 main.ts 中导入 Zone.js 文件而不是 polyfills.ts,否则我会得到错误:

in this configuration angular requires zone.js



我正在使用 Angular8、Typescript 3.4.5 和节点 12.4.0。我究竟做错了什么?

我的 tsconfig.json:
{
"angularCompilerOptions": {
"preserveWhitespaces": false
},
"compileOnSave": false,
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"compilerOptions": {
"outDir": "./dist/out-tsc/app",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"module": "esnext",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es6",
"dom"
],
"baseUrl": "./src"
}
}

最佳答案

问题来自 web-animations-js .

从 Angular 6 开始,它是 不再需要 :

We’ve updated our implementation of Animations to no longer need the web animations polyfill. This means that you can remove this polyfill from your application and save approximately 47KB of bundle size, while increasing animations performance in Safari at the same time.



https://angular.io/guide/browser-support#enabling-polyfills

我从 polyfills 和 package.json 中删除了它,错误消失了。

关于angular - 升级到 Angular 8 : Changing the target to "es2015" in tsconfig. json 导致 polyfills-2015 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56458488/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com