2017-02-20 35 views
1

我已經升級我的應用程序的最新角4(β-8)版本。但是我一直有以下錯誤:Angular4我應該用什麼定義可迭代的

@angular\core\src\change_detection\differs\iterable_differs.d.ts:14: TS2304 Cannot find name 'Iterable'

我沒有擡頭的更新日誌,發現:

Iterable<T>的定義現在需要正確編譯角應用。在運行時不需要支持Iterable<T>,但類型定義Iterable<T>必須可用。

我應該在這裏使用的Iterable的定義是什麼?

編輯:

tsconfig.json

"compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    /* for reading your ts source while debugging from a browser */ 
    "sourceMap": true, 
    /* the following two settings are required for angular2 annotations to work*/ 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators":true, 
    /* noImplicitAny when you want your typescript to be fully typed */ 
    "noImplicitAny":false, 
    "suppressImplicitAnyIndexErrors":true, 
    "noFallthroughCasesInSwitch":true, 
    "noImplicitReturns":true, 
    "outDir": "./target/ts" 
    } 
+0

什麼是您的打字稿版本? tsc --version – MikeOne

+0

我的ts版本是2.1.4 – Scipion

+0

好的,我在這裏抓住。您可以嘗試將「es2015.iterable.ts」添加到tsconfig.json中的「lib」定義中,但是,實際上並不需要這樣做。那裏有什麼庫? 「es6」?或更低? – MikeOne

回答

4

繼其更改日誌中所述的migration你應該添加es2015.iterable作爲一個lib裏面你tsconfig.json

{ 
    ..., 
    "compilerOptions" : { 
    ..., 
    "lib": ["es6", "dom", "es2015.iterable"] 
    } 
} 
+0

我嘗試了將字符串添加到'lib'的方法,但是我繼續看到'Can not find name'Iterable''問題。我也嘗試了@Naveed Ahmed的建議(下圖),但它沒有幫助 我可能會錯過什麼? – user3344978

+0

聽起來我的編譯器沒有尋址正確的'tsconfig.json'。或者你還沒有在'compilerOptions'對象中放置'lib'條目? – PierreDuc

+0

我通過重新安裝分型與1.x的版本,我正在使用的'ambient'早期 – user3344978

0

我試圖接受的答案對於這個問題,但它不適用於我的情況。

在我來說,我在下面一行在我main.ts

///<reference path="./../typings/globals/core-js/index.d.ts"/> 

其固定的問題,希望這可以幫助別人。

相關問題