jquery - Typescript 編譯器錯誤。名稱 'boolean' 在當前範圍中不存在
我正在嘗試建立一個使用 Typescript 的環境。
我已經使用 npm 在我的 OS X 上安裝了 TypeScript,並從 https://github.com/borisyankov/DefinitelyTyped 下載了最新的 jquery/jquery.d.ts
在命令列中執行 tsc(使用整合提供的工具得到相同的結果)以以下錯誤結束:
The name 'boolean' does not exist in the current scope
問題也出現了(類似,但未找到的類型是「_element」)與 lib.d.ts 類型註解文件。
我正在使用 TypeScript 編譯器版本 0.9.0.0。
後續編輯:
我肯定迷路了,試著從...獲取 jquery.d.ts
http://typescript.codeplex.com/SourceControl/changeset/view/fe3bc0bfce1f#bin/jquery.d.ts
而現在我在編譯它時又遇到了不同的問題:
jquery.d.ts(37,18): error TS1023: Index signature parameter type must be 'string' or 'number'
我使用的 ts 檔案與編譯器之間是否存在版本不匹配,如果有,我該如何解決呢?謝謝。
答案#1
你應該試試這個版本:https://github.com/borisyankov/DefinitelyTyped/blob/master/jquery/jquery.d.ts
也可以嘗試卸載並重新安裝 TypeScript。
npm uninstall typescript
npm uninstall -g typescript
npm install typescript
在做那件事之前,我也很好奇 tsc -version 顯示的是什麼。在上述步驟之後有改變嗎?
