title: import html template in typescript
body: <p>I'm trying to <code>import</code> my html template so that webpack will recognize them and include them when I build. (<code>webpack -d</code>)</p>
  
  <p>According to <a href="https://github.com/Microsoft/TypeScript/issues/2709" rel="nofollow noreferrer">this GitHub issue</a> I should do this</p>
  
  <pre><code>declare module '*.html' {
      const _: string;
      export default _;
  }
  </code></pre>
  
  <p>Then <code>import template from './myTemplate.html';</code> should work.</p>
  
  <p>But it doesn't quite do the trick.</p>
  
  <pre><code>import template from './myTemplate.html';
  console.log(template); // undefined
  </code></pre>
  
  <p>However this <em>"works"</em></p>
  
  <pre><code>import * as template from './myTemplate.html';
  console.log(template); // &lt;p&gt;Hello world!&lt;/p&gt;
  </code></pre>
  
  <p>Very strange.</p>
  
  <p>But now this doesn't work</p>
  
  <pre><code>$routeProvider.when("/test", {
      template: template, // ERROR! template is typeof(*.html) expected string
      controller: MyController,
      controllerAs: "$ctrl"
  });
  </code></pre>
  
  <p>However if I change my *.html module to</p>
  
  <pre><code>declare module '*.html' {
      const _: string;
      export = _; // changed this
  }
  </code></pre>
  
  <p>I can now do</p>
  
  <pre><code>import * as template from './myTemplate.html';
  
  $routeProvider.when("/test", {
      template: template, // Great success!
      controller: MyController,
      controllerAs: "$ctrl"
  });
  </code></pre>
  
  <p>It works, but why doesn't <code>import template from './myTemplate.html';</code> work? <strong>What am I doing wrong</strong> as the others in the GitHub issue seemed to get it to work like that.</p>