VisualStudio has problem when multiple versions of Typescript are installed

You can have several versions of Typescript installed on your machine and each project in Visual Studio can be configured to use different version by specifying that version in .csproj file.

Like this

<TypeScriptToolsVersion>1.6</TypeScriptToolsVersion>
<TypeScriptToolsVersion>1.6</TypeScriptToolsVersion>

But you might still have problems with IntelliSense for some native javascript objects. VisualStudio uses file lib.d.ts  to learn interfaces of window objects, events, etc. This lib.d.ts is updated with each version of typescript you install. When some interface become obsolete, it is removed from lib.d.ts, and VisualStudio then marks usage of such an interface as invalid and refuses to build.

Now you have problem.

You can either manually update the lib.d.ts file yourself, but that is not recommended. It is the default definition of interfaces, so obviously you do not want to mess it up.

Luckily you can specify your own version of lib.d.ts to be used in your specific project by using /// <reference path=”custom/path/to/lib.d.ts” /> in project-specific _reference.ts file.

Now everything should work again 🙂

Additional resources to study

Visual Studio 2015 compiles ALL typescript files when SINGLE file is changed

Which version of TypeScript is installed?

not-sure-if-typescript