1
我有一个使用typescript(2.0.0)的angular2应用程序(2.0.0)。在我tsconfig我编译此行ES6:Angular2应用程序不能在IE中与ES6一起工作,并使用ES5编译错误
"target": "es6",
它在Chrome和边缘做工精细,但它不是在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-j包括在内。我认为这是解决这个问题的方法。
我应该瞄准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"
]
}
我一直在使用es6。当我改用es5时,有很多错误。这只是少数。 我添加了TS定义,如下所示:/// 但仍然出现错误。 –
与那些TypeDefinition你仍然得到承诺的错误?这也是:/// 。导入此TS定义后,至少应出现Promise错误。 –
dokkis
我看到我也瞄准了es5,但是如果我尝试使用Promise,它会从node_modules/typescript/lib/lib.es2015.promise.d.ts中导入 – dokkis