title: Visual Studio Code complains that it "Cannot find namespace" for types defined in *.d.ts files
body: <p>I created a new project using the <a href="https://github.com/Swiip/generator-gulp-angular" rel="noreferrer">gulp-angular</a> Yeoman generator with language set to TypeScript. Then ran the <a href="http://gulpjs.com/" rel="noreferrer">Gulp</a> build process and also opened the page in a web browser, which all worked without any bigger problems. I only had to replace <code>ref: "master"</code> in the <code>tsd.json</code> with <code>ref: "1.4.1"</code> to make the build work. Basically I executed following commands:</p>
  
  <pre><code>yo gulp-angular
  vim tsd.json
  gulp
  gulp serve
  code .
  </code></pre>
  
  <p>Afterwards I opened the project in <a href="https://code.visualstudio.com/" rel="noreferrer">Visual Studio Code</a>.</p>
  
  <p>Now, Visual Studio Code complains for example that it <em>"Cannot find namespace 'ng'"</em> for each occurrence where <a href="https://angularjs.org/" rel="noreferrer">AngularJS</a> data types are used. It also complains about <a href="http://momentjs.com/" rel="noreferrer">MomentJS</a> and other typings defined in <code>*.d.ts</code> files.</p>
  
  <p>The project's <code>tsd.json</code> looks like this:</p>
  
  <pre><code>{
    "version": "v4",
    "repo": "borisyankov/DefinitelyTyped",
    "ref": "1.4.1",
    "path": ".tmp/typings",
    "bundle": ".tmp/typings/tsd.d.ts"
  }
  </code></pre>
  
  <p>The <code>.tmp/typings</code> folder contains following files:</p>
  
  <pre><code>angular-ui-router/angular-ui-router.d.ts
  angularjs/angular-animate.d.ts
  angularjs/angular-cookies.d.ts
  angularjs/angular-mocks.d.ts
  angularjs/angular-resource.d.ts
  angularjs/angular-sanitize.d.ts
  angularjs/angular.d.ts
  jquery/jquery.d.ts
  moment/moment-node.d.ts
  moment/moment.d.ts
  toastr/toastr.d.ts
  tsd.d.ts
  </code></pre>
  
  <p>To give an example of one of the source files where Visual Studio Code is complaining, here is the <code>navbar.directive.ts</code> file:</p>
  
  <pre><code>module editorTs {
    'use strict';
  
    /** @ngInject */
    export function acmeNavbar(): ng.IDirective {
  
      return {
        restrict: 'E',
        scope: {
          creationDate: '='
        },
        templateUrl: 'app/components/navbar/navbar.html',
        controller: NavbarController,
        controllerAs: 'vm',
        bindToController: true
      };
  
    }
  
    /** @ngInject */
    class NavbarController {
      public relativeDate: string;
  
      constructor(moment: moment.MomentStatic) {
        this.relativeDate = moment(1444135396045).fromNow();
      }
    }
  }
  </code></pre>
  
  <p>In this file Visual Studio Code is complaining about the <code>ng.IDirective</code> type that it <em>"Cannot find namespace 'ng'"</em> and it is complaining about the <code>moment.MomentStatic</code> type that it <em>"Cannot find namespace 'moment'"</em>.</p>
  
  <p><strong>edit:</strong></p>
  
  <p>Explicitely referencing the type definition files by adding the following to the top of <code>navbar.directive.ts</code> removes the problem:</p>
  
  <pre><code>/// &lt;reference path="../../../../.tmp/typings/angularjs/angular.d.ts"/&gt;
  /// &lt;reference path="../../../../.tmp/typings/moment/moment.d.ts"/&gt;
  </code></pre>
  
  <p>But these files are already referenced in <code>.tmp/tsd.d.ts</code>, which contains the following:</p>
  
  <pre><code>/// &lt;reference path="angular-ui-router/angular-ui-router.d.ts" /&gt;
  /// &lt;reference path="angularjs/angular-animate.d.ts" /&gt;
  /// &lt;reference path="angularjs/angular-cookies.d.ts" /&gt;
  /// &lt;reference path="angularjs/angular-mocks.d.ts" /&gt;
  /// &lt;reference path="angularjs/angular-resource.d.ts" /&gt;
  /// &lt;reference path="angularjs/angular-sanitize.d.ts" /&gt;
  /// &lt;reference path="angularjs/angular.d.ts" /&gt;
  /// &lt;reference path="jquery/jquery.d.ts" /&gt;
  /// &lt;reference path="moment/moment-node.d.ts" /&gt;
  /// &lt;reference path="moment/moment.d.ts" /&gt;
  /// &lt;reference path="toastr/toastr.d.ts" /&gt;
  </code></pre>
  
  <p>So there should be no need to explicitly reference the files?</p>