2016-10-14 65 views
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" 
    ] 
} 

回答

0

的第一个错误,我认为你应该导入打字稿定义https://github.com/borisyankov/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts

对于第二个,你可以请粘贴行代码?

+0

我一直在使用es6。当我改用es5时,有很多错误。这只是少数。 我添加了TS定义,如下所示:/// 但仍然出现错误。 –

+0

与那些TypeDefinition你仍然得到承诺的错误?这也是:/// 。导入此TS定义后,至少应出现Promise错误。 – dokkis

+0

我看到我也瞄准了es5,但是如果我尝试使用Promise,它会从node_modules/typescript/lib/lib.es2015.promise.d.ts中导入 – dokkis

相关问题