2017-06-09 42 views
0

使用Windows 10的企業,爲什麼VSCode全新安裝認爲它有TypeScript?

上幾臺虛擬機就這個問題和實驗花了幾個小時後,

事實#1

當我打開vscode一個的.ts文件,它認爲它實際上具有打字稿2.3.4每截圖如下:

enter image description here

事實#2 然而,當我嘗試運行VSCode(控制移B)一個的.ts文件,我得到這個錯誤:

'tsc' is not recognized as an internal or external command, 

事實#3

當我搜索我的所有硬盤, tsc.cmd僅作爲Visual Studio 2015的一部分存在於以下位置。但它不是VSCode的一部分

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\node_modules\.bin\tsc.cmd 

事實#4 的打字稿文檔錯誤地指出

「VS Code ships with a recent stable version of the TypeScript language service」

https://code.visualstudio.com/Docs/languages/typescript

事實#5

經歷了一些其他SO帖子: Does VS Code install TypeScript, and if so: where?我知道我必須手動安裝打字稿和處理以下版本衝突警告

"Version mismatch! global tsc (2.1.5) != VS Code's language service (2.2.1). Inconsistent compiler errors might occur"

這裏解釋:https://code.visualstudio.com/Docs/languages/typescript

問:

爲什麼和新鮮如何VSCode安裝認爲它在上面的屏幕截圖中顯示了TypeScript 2.3.4?

回答

0

由於@Michael Szul said,VS代碼附帶打字稿語言服務:

VS Code ships with a recent stable version of the TypeScript language service and it may not match the version of TypeScript installed globally on your computer or locally in your workspace.

VS代碼不認爲它有編譯安裝了打字稿,但該VS代碼依賴於語言服務的版本爲2.3.4(在你的情況)。

在引擎蓋下,將TypeScript集成到編輯器中,只是另一個VS代碼擴展。但它並未顯示擴展面板,因爲它始終安裝在VS代碼中。同樣,這不是TypeScript編譯器本身,而是將TypeScript編譯器特性集成到VS Code中。

source code of the TypeScript extension甚至與VS代碼的其餘部分位於同一個存儲庫(至少直到2017年6月)。

順便說一句,前段時間我回答了一個類似的問題,也許它有幫助:What TypeScript version is Visual Studio Code using? How to update it?

2

VS代碼附帶的打字稿語言服務

VS Code ships with a recent stable version of the TypeScript language service and it may not match the version of TypeScript installed globally on your computer or locally in your workspace. The active version of the TypeScript language service is displayed in the Status Bar when viewing a TypeScript or JavaScript file:

這是允許智能感知,語法高亮,等等的API .--不是編譯器本身。

相關問題