Allan Xu
Allan Xu

Reputation: 9368

Why and how VSCode fresh install thinks it has TypeScript?

Using Windows 10 Enterprise,

After spending a few hours on this and experiment on a few VMs,

Fact #1

When I open a .ts file in vscode, it thinks that it actually has TypeScript 2.3.4 per below screenshot:

enter image description here

Fact#2 However, when I try to run a .ts file in VSCode (control-shift-b) I get this error:

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

Fact#3

When I search all my HDD, tsc.cmd only exists as part of Visual Studio 2015 at below location. But it is not part of VSCode

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

Fact#4 The typescript documentation falsely states that

“VS Code ships with a recent stable version of the TypeScript language service”

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

Fact#5

Going through some other SO posts: Does VS Code install TypeScript, and if so: where? I know that I have to manually install TypeScript and deal with the below version conflict warning

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

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

Question:

Why and how VSCode fresh install thinks it has TypeScript 2.3.4 shown in the above screenshot?

Upvotes: 0

Views: 543

Answers (2)

Fabian Lauer
Fabian Lauer

Reputation: 9907

As @Michael Szul said, VS Code ships with the TypeScript language service:

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 Code doesn't think it has the TypeScript compiler installed, however the language service that VS Code relies on is at version 2.3.4 (in your case).

Under the hood, the TypeScript integration into the editor is just another VS Code extension. It doesn't show up the extension panel, though, since it's always installed in VS Code. Again, this is not the TypeScript compiler itself, instead it's the integration of TypeScript compiler features into VS Code.

The source code of the TypeScript extension even resides in the same repository as the rest of VS Code (at least until June 2017).

BTW, I answered a similar question a while ago, maybe it helps: What TypeScript version is Visual Studio Code using? How to update it?.

Upvotes: 0

user8086575
user8086575

Reputation:

VS Code ships with the TypeScript language service:

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:

This is the API that allows for intellisense, syntax highlighting, etc.--not the compiler itself.

Upvotes: 2

Related Questions