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