How to install TypeScript 2.2 onto Visual Studio 2017

Carl in 't Veld picture Carl in 't Veld · Dec 21, 2017 · Viewed 10.7k times · Source

Some people in our team have both Visual Studio 2015 and Visual Studio 2017 installed. Others only have the latest Visual Studio 2017 (15.5). With the latter, we noticed that our TypeScript project in the IDE is generating all kinds of unexpected errors due to all kinds of lib.es2015.d.ts issues.

Our projects use TypeScript 2.2, whereas the latest Visual Studio 2017 (15.5) comes with TypeScript 2.5.

We discovered that the Visual Studio TypeScript SDK is installed in the following path:

  • C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.2
  • C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.5

We noticed that 15.5 comes with a new property in the csproj property screen which allows direct mutation of the wanted TypeScript version. As the project requires 2.2 which is not installed, the dropdown states the missing 2.2 bits.

What we have tried to fix this:

  1. Installed the TypeScript 2.2 SDK for Visual Studio 2015 (for 2017 there is no separate install). Unfortunately it looks like this package does not come with the language service tsserver.js. Did not work. Url: http://download.microsoft.com/download/6/D/8/6D8381B0-03C1-4BD2-AE65-30FF0A4C62DA/TS-2.2-dev14update3-20170221.2/TypeScript_Dev14Full.exe
  2. Played with the NuGet-package Microsoft.TypeScript.Compiler and installed 2.2.1 (no 2.2.2 available?). This didn't seem to solve anything. Not clear to us how this package really integrates into something. Even after adding the specific property TypeScriptNuGetToolsVersion.
  3. Played with the NuGet-package Microsoft.TypeScript.MSBuild and installed version 2.2.2. Unfortunately, this only influences the MSBuild process and not the editor experience. MSBuild is not relevant to us as we are using the Angular CLI for really building / watching the TypeScript source code.
  4. Copied over the 2.2 bits of one of our Visual Studio 2015 installations. This enabled the 2.2 menu option in the csproj property screen. But, we still experience clashes with lib.es2015.d.ts. What we discovered is that the SDK seems to always use the latest version, in our case 2.5. We also installed 2.6, and then it started to use 2.6.
  5. Ultimately we just removed the 2.6 folder completely and created a copy of the 2.2 folder with the name 2.6. And now it works. But this really feels like a hack!

To summarize our questions:

  • What is the best way to install TypeScript SDK 2.2 onto Visual Studio 2017 (15.5)?
  • What is the best way to really enforce the usage of lib.es2015.d.ts from version 2.2?

Answer

PmanAce picture PmanAce · Dec 21, 2017

In "Get Tools and Features" under the Tools menu you should be able to install different versions of TypeScript under the individual components tab.