gpt4 book ai didi

typescript - Angular 2 : Many errors compiling to ES5

转载 作者:搜寻专家 更新时间:2023-10-30 21:42:20 25 4
gpt4 key购买 nike

当在 tsconfig.json 文件中设置为 es5 时,我无法编译我的 Angular 2 应用程序。如果我将它更改为 es6,我所有的编译器错误都会消失。

配置文件:

"compilerOptions": {
"target": "es5",
"module": "system",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"moduleResolution": "node"
},
"files": [ ...

索引.html

<script src="~/node_modules/systemjs/dist/system.src.js"></script>
<script src="~/node_modules/es6-shim/es6-shim.min.js"></script>
<script src="~/node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="~/node_modules/moment/min/moment.min.js"></script>
<script>
System.config({
defaultJSExtensions: true,
baseURL: '/ECAV.Admin/node_modules',
packages: {
'app': { format: 'register', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' }
},
paths: {
'angular2/*': 'angular2/*',
'rxjs': 'rxjs/bundles/Rx.js',
'linqsharp': 'linqsharp/built/linqsharp',
'highcharts': 'highcharts',
'ng2-highcharts': 'ng2-highcharts/ng2-highcharts',
'lodash': 'lodash/lodash'
},
map: {
moment: 'moment/moment.js'
}
});
</script>
<script src="/Admin/node_modules/rxjs/bundles/Rx.js"></script>
<script src="/Admin/node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="/Admin/node_modules/lodash/lodash.js"></script>

示例错误(其中有很多来自库类):

Build: Cannot find name 'Set'.  Admin   C:\dev\ecav\Admin\node_modules\angular2\src\common\directives\ng_class.d.ts 72  

我的一个要求是在 IE11 中运行这个网站,所以我需要 es5。

如有任何帮助,我们将不胜感激。

最佳答案

如果您要转译为 ES5,您可能需要设置 ///<reference path="node_modules/angular2/typings/browser.d.ts"/>在您的主要 typescript 文件中。

发件人:https://stackoverflow.com/a/35737470/3279156

关于typescript - Angular 2 : Many errors compiling to ES5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36544153/

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