title: Errors on Visual Studio AngularJS Project after upgrading TypeScript on a different project
body: <p><em>UPDATE</em> - I just discovered this article:</p>
  
  <p><a href="http://blog.davidjs.com/2015/11/visualstudio-has-problem-when-multiple-versions-of-typescript-are-installed/" rel="nofollow noreferrer">http://blog.davidjs.com/2015/11/visualstudio-has-problem-when-multiple-versions-of-typescript-are-installed/</a></p>
  
  <p>which suggests that my problem is likely this:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>The article says this:</p>
  
  <blockquote>
    <p>you can specify your own version of lib.d.ts to be used in your
    specific project by using </p>
  </blockquote>
  
  <pre><code>/// &lt;reference path=”custom/path/to/lib.d.ts” /&gt;
  </code></pre>
  
  <blockquote>
    <p>in project-specific _reference.ts
    file.</p>
  </blockquote>
  
  <p>How do I do that though? The compiler is complaining about the lib.d.ts that's in the solution that doesn't build, so which lib.d.ts do I have to specify, for the lib.d.ts to work with TypeScript 1.8?</p>
  
  <hr>
  
  <p><em>The problem:</em></p>
  
  <p>I have a Visual Studio 2015 solution that contains a number of projects. I've upgraded one of the projects (which has AngularJS) to a hybrid AngularJS/Angular app that uses TypeScript 2.6.2, and now one of the other projects (a purely AngularJS app) in the same solution fails to compile because of TypeScript errors.</p>
  
  <p>The newly upgraded project is compiling fine (including the TypeScript), and it compiles via Visual Studio using the following tsconfig.json file:</p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "es5",
      "module": "system",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": [ "es2015", "dom" ],
      "noImplicitAny": false,
      "suppressImplicitAnyIndexErrors": true,
      "noStrictGenericChecks": true
    },
    "include": [ "**/*.ts" ],
    "exclude": [
      "node_modules"
    ]
  }
  </code></pre>
  
  <p>When I go into the project root folder via the command line in Windows, then type 'tsc -v', the output is 'Version 2.6.2', which I believe confirms the TypeScript version that Visual Studio is building against for this project.</p>
  
  <p>The other project (that contains the 'pure' AngularJS code) only builds using Visual Studio (there isn't any tsc compilation using CLI). The project now shows *.ts errors in Visual Studio that weren't there before, including the following:</p>
  
  <p><a href="https://i.stack.imgur.com/GMdT3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GMdT3.jpg" alt="enter image description here"></a></p>
  
  <p>And I'm also seeing various *.d.ts errors:</p>
  
  <p><a href="https://i.stack.imgur.com/oeWQx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oeWQx.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/Ie6yI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ie6yI.png" alt="enter image description here"></a></p>
  
  <p>The errors must be showing due to some kind of configuration change as there haven't been any code changes to the project, however I don't understand this because the project compiles through visual studio and <em>doesn't</em> use a tsconfig.json, and the project settings haven't changed. Here they are:</p>
  
  <p><a href="https://i.stack.imgur.com/jgxkM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jgxkM.png" alt="enter image description here"></a></p>
  
  <p>And the relevant .csproj settings:</p>
  
  <pre><code>&lt;PropertyGroup&gt;
      &lt;TypeScriptTarget&gt;ES5&lt;/TypeScriptTarget&gt;
      &lt;TypeScriptToolsVersion&gt;1.8&lt;/TypeScriptToolsVersion&gt;    
      ... etc
  </code></pre>
  
  <p>When I was getting the 'hybrid' Angular/AngularJS project to work, at one stage I installed the 'TypeScript compiler v.2.6.2' globally in the Visual Studio solution using the VS nuget package manager, however I've since uninstalled it, and there has been nothing written to a packages.config file that's under source control. In any case the 'TypeScriptToolsVersion' in the project that's broken still points to v1.8 so I don't think that installing/uninstalling the nuget package is what's caused the problem. Here is what I now have in the C:\Program Files (x86)\Microsoft SDKs\TypeScript folder that Visual Studio usually uses when compiling TypeScript</p>
  
  <p><a href="https://i.stack.imgur.com/cNy0U.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cNy0U.jpg" alt="enter image description here"></a></p>
  
  <p>I notice that the 'versions' file has 'LastKnownTypeScriptVersion' 2.6 as shown below, however when I edit that to 1.8 the project that has the errors now fails to load when I close and re-open Visual Studio</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;LastKnownTypeScriptVersion&gt;2.6&lt;/LastKnownTypeScriptVersion&gt;
    &lt;/PropertyGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>When I was configuring the hybrid app to work, I also did a global npm install of TypeScript 2.6.2, as well as an npm install of TypeScript 2.6.2 into the new 'hybrid app' project, however Visual Studio shouldn't be using those at all as those should be completely independent installs of TypeScript.</p>
  
  <p>Is there anything obvious I could be missing here? I need some more ideas of what I can look at. Any comments or answers that give me some clue as to what's going on or what I could look at will be appreciated!</p>