title: Is it possible to specify a webpack loader in a TypeScript import?
body: <p>My project is written in TypeScript and uses webpack to bundle scripts.  All .ts files go through the TypeScript loader in order to transpile them to JavaScript; what I am trying to figure out how to do is to have some some specific imports go through a custom webpack loader.  Something like:</p>
  
  <pre><code>import widget from 'myCustomLoader!./widget';
  </code></pre>
  
  <p>Of course, this doesn't work because TypeScript has no idea how to interpret webpack's loader syntax.  Ideally TypeScript would just ignore everything before the ! and just look at './widget' for the purposes of type checking.</p>
  
  <p>Another possibility I considered is to have all .ts files go through myCustomLoader by specifying it in webpack.config, and then using some sort of querystring to signal it to do it's work.  For example:</p>
  
  <pre><code>import widget from './widget?myCustomLoader=true';
  </code></pre>
  
  <p>But TypeScript still can't handle that.  Obviously using require directly will work:</p>
  
  <pre><code>var widget = require('myCustomLoader!./widget');
  </code></pre>
  
  <p>...but then I've lost all the type safety that TypeScript offers.  Can anyone suggest a way to specify (or otherwise interact with) a custom webpack loader and still keep the type safety benefits of TypeScript import syntax?</p>