title: Importing TypeScript external modules using aliases supplied through requirejs.config
body: <p>Here's my folder structure:<br/></p>
  
  <ul>
  <li>app
  
  <ul>
  <li>app1
  
  <ul>
  <li>core.ts</li>
  </ul></li>
  <li>app2
  
  <ul>
  <li>util.ts</li>
  </ul></li>
  <li>packages
  
  <ul>
  <li>features
  
  <ul>
  <li>feature1
  
  <ul>
  <li>index.ts</li>
  </ul></li>
  </ul></li>
  </ul></li>
  <li>app.ts (bootstraps the application)</li>
  <li>main.ts (main entry point)</li>
  </ul></li>
  <li>vendor
  
  <ul>
  <li>requirejs (from <a href="https://requirejs.org" rel="nofollow">https://requirejs.org</a>)</li>
  </ul></li>
  <li>index.html</li>
  </ul>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Test RequireJS with TypeScript&lt;/title&gt;
      &lt;script src="vendor/requirejs/require.js" data-main="app/main"&gt;&lt;/script&gt;
    &lt;/head&gt;
   &lt;body&gt;
  
  
   &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Notice in <code>paths</code>, I have added an alias for <code>feature1</code> as well. <br/>
  <strong>main.ts</strong></p>
  
  <pre><code>'use strict';
  
  require.config({
    paths: {
      app1: 'app1',
      app2: 'app2',
      feature1: 'packages/features/feature1'
    },
    deps: ['app']
  });
  </code></pre>
  
  <p><strong>core.ts (app1)</strong></p>
  
  <pre><code>class Core {
    name = 'Core';
  }
  
  export = Core;
  </code></pre>
  
  <p><strong>util.ts (app2)</strong></p>
  
  <pre><code>class Util {
    name = 'Util';
  }
  
  export = Util;
  </code></pre>
  
  <p><strong>index.ts (feature1)</strong></p>
  
  <pre><code>class Util {
    name = 'Util';
  }
  
  export = Util;
  </code></pre>
  
  <p>From <code>app.ts</code>, I want to refer the <code>core.ts</code>, <code>util.ts</code> and <code>feature1's</code> <code>index.ts</code> files. This is how I attempted first and worked perfectly:<br/></p>
  
  <pre><code>/// &lt;amd-dependency path="feature1/index" name="Feature" /&gt;
  declare var Feature: any;
  
  import Core = require('app1/core');
  import MyUtil = require('app2/util/myutil');
  
  var c = new Core();
  console.log(c.name);
  
  var util = new MyUtil();
  console.log(util.name);
  
  var f = new Feature();
  console.log(f.name);
  </code></pre>
  
  <p>Then I tried doing the following but failed. Seems like <code>require()</code> only understands relative path and it doesn't understands the aliases provided through <code>require.config(...)</code>:</p>
  
  <pre><code>import Core = require('app1/core');
  import MyUtil = require('app2/util/myutil');
  import Feature = require('feature1/index'); // ERROR!: Cannot find module `feature1/index`
  
  var c = new Core();
  console.log(c.name);
  
  var util = new MyUtil();
  console.log(util.name);
  
  var f = new Feature();
  console.log(f.name);
  </code></pre>
  
  <p>Is my understanding correct? Any best practice to refer other external modules?</p>