title: Could not reference properly d3js (4.7) from TypeScript (2.4.2)
body: <p>I am starting to develop my own custom visualization for <strong>Power BI</strong>. To do this I have prepared my <strong>development</strong> environment but I require to use <strong>D3js</strong> javascript framework from TypeScript. I already installed <strong>D3js</strong> in my environment using <strong>npm</strong> and typings but I could not reference correctly to use it from my TypeScript code.</p>
  
  <p>D3js is installed using typings so D3js is installed as a typescript type. The <code>index.d.ts</code> file (from D3) contains a ts module declaration where the module is exported as a namespace, here start the problem, the namespace declaration is marked as incorrect with the following message</p>
  
  <h2>Global module exports may only appear at top level</h2>
  
  <p>This is the actual code from index.d.ts file (from d3js)</p>
  
  <pre><code>    // Generated by typings
      // Source: 
  
      module 'd3' {
      // Type definitions for D3JS d3 standard bundle 4.7
      // Project: https://github.com/d3/d3
      // Definitions by: Tom Wanzek &lt;https://github.com/tomwanzek&gt;, Alex Ford &lt;https://github.com/gustavderdrache&gt;, Boris Yankov &lt;https://github.com/borisyankov&gt;
      // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  
      export as namespace d3; //this is the line marked as incorrect
  
      export * from 'd3-array';
      export * from 'd3-axis';
      export * from 'd3-brush';
      export * from 'd3-chord';
      export * from 'd3-collection';
      export * from 'd3-color';
      export * from 'd3-dispatch';
      export * from 'd3-drag';
      export * from 'd3-dsv';
      export * from 'd3-ease';
      export * from 'd3-force';
      export * from 'd3-format';
      export * from 'd3-geo';
      export * from 'd3-hierarchy';
      export * from 'd3-interpolate';
      export * from 'd3-path';
      export * from 'd3-polygon';
      export * from 'd3-quadtree';
      export * from 'd3-queue';
      export * from 'd3-random';
      export * from 'd3-request';
      export * from 'd3-scale';
      export * from 'd3-selection';
      export * from 'd3-shape';
      export * from 'd3-time';
      export * from 'd3-time-format';
      export * from 'd3-timer';
      export * from 'd3-transition';
      export * from 'd3-voronoi';
      export * from 'd3-zoom';
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Finally, I know that TypeScript has suffer a big change on version <strong>1.5</strong>, &lt;<strong>1.5</strong> there were not namespaces but <strong>external modules</strong> maybe the <strong>D3js</strong> code is not tuned with the latest changes no TypeScript</p>
  
  <p>How can I define a namespace from a module? 
  Do I need to change the module for other object?</p>