tsc - error TS2304 Cannot find name 'Set'/'Promise'

編譯typescript,遇到:

tsc:
node_modules/@angular/platform-browser/src/facade/collection.d.ts(10,23): error TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser/src/facade/collection.d.ts(11,25): error TS2304: Cannot find name 'Map'.
node_modules/rxjs/Observable.d.ts(10,66): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(66,60): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(66,70): error TS2304: Cannot find name 'Promise'.

其中類似 Promise, Map 是已經加入到了ES6的 specification中,但是typescript還不認識
解決:

npm install --save-dev typings
$(npm bin)/typings -v
$(npm bin)/typings search core-js
$(npm bin)/typings install --global --save dt~core-js

再次執行tsc,沒報錯了。

發佈了154 篇原創文章 · 獲贊 13 · 訪問量 23萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章