我有一个使用打字稿(2.0.0)的angular2应用程序(2.0.0)。在我的 tsconfig 中,我使用这一行编译为 es6:
"target": "es6",
它在 Chrome 和 Edge 中运行良好,但在 IE11 中无法运行。
我将其更改为目标 es5,但随后出现几个编译错误,例如:
ClientApp\app\services\tenant.service.ts(9,16): error TS2304: Cannot find name 'Promise'.
ClientApp\app\components\manage\users.component.ts(70,31): error TS2339: Property 'json' does not exist on type '{}'.
这确实会产生输出,并且在运行时似乎可以在 IE11 和其他浏览器中工作(但我还没有测试所有内容)。我仍然不喜欢编译错误。
我有 core-js 包括在内。我认为这是解决此问题的方法。
我应该瞄准 5 还是 6?
es6应该在IE中工作吗?有没有我缺少的垫片?
如何使用 es5 并摆脱编译错误?
这是我的 tsconfig.json:
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"skipLibCheck": true
},
"exclude": [
"node_modules"
]
}