title: TypeScript Import Path Alias
body: <p>I am currently working on a TypeScript application which is comprised of multiple Node modules written in TypeScript, that are installed into the <code>node_modules</code> directory.</p>
  
  <p>Before continuing, I would like to note that I am using TypeScript 2.0, I am not adverse to using the 2.1 dev release if need be as well. I just want to get this working.</p>
  
  <p>The structure of each Node module is something along the lines of:</p>
  
  <pre><code>dist/
      es2015/
          index.js
          utils/
              Calculator.js
              Calculator.d.ts
              Date.js
              Date.d.ts
              Flatpack.js
              Flatpack.d.ts
  src/
      index.ts
      utils/
          Calculator.ts
          Date.ts
          Flatpack.ts
  </code></pre>
  
  <p>The dist folder is the generated source, with this path being configured using <code>outDir</code> inside of my <code>tsconfig.json</code> file. I have also configured the <code>main</code> property in my <code>package.json</code> to be <code>dist/es2015/index.js</code>.</p>
  
  <p><strong>Important things to note:</strong></p>
  
  <ul>
  <li>In my project I am using <code>moduleResolution</code> type of <code>node</code></li>
  <li>I am using TypeScript 2.0</li>
  <li>I am not asking how to import a file from within the package. I am installing the package via Npm and then importing it via <code>packagename/</code> from within an application that is using this module.</li>
  </ul>
  
  <p>Now comes my question/issue. Whilst importing files from this module, I would like to be able to do this:</p>
  
  <pre><code>import {Sin, Cos, Tan} from "common-utils/utils/Calculator";
  </code></pre>
  
  <p>However, the file cannot resolve to the <code>dist/es2015/utils</code> directory. Ideally I would like my imports to resolve from this specific <code>dist</code> folder and not from the root, which is what appears to be happening.</p>
  
  <p>The above import needs to be written as the following to get it to work:</p>
  
  <pre><code>import {Sin, Cos, Tan} from "common-utils/dist/es2015/utils/Calculator";
  </code></pre>
  
  <p>However, writing <code>dist/es2015</code> each time is not ideal and it just makes some of the imports look really long. Is there a way I can configure my module to resolve to the <code>dist/es2015</code> directory? I don't want to have to put in overrides inside of my project, ideally each module would specify where files are resolved from. </p>
  
  <p>If you are still unsure what I am asking (and I apologise if this is confusing) in Jspm when you create a plugin/module to be used with Jspm, you can specify inside of the <code>package.json</code> for the module something like the following:</p>
  
  <pre><code>  "jspm": {
      "registry": "npm",
      "jspmPackage": true,
      "main": "my-module",
      "format": "amd",
      "directories": {
        "dist": "dist/amd"
      },
  </code></pre>
  
  <p>I am looking for the equivalent of the above in TypeScript (if it exists). A mapping directive, so when the end user runs <code>npm install my-cool-package</code> and then in their app tries to import something, all imports by default resolve to the <code>commonjs</code> directory (the above example for Jspm uses amd, but same premise).</p>
  
  <p>Is this possible or am I misunderstanding something here? I know some new path mapping features were added into the latest release, but documentation on using them is almost nonexistent.</p>