title: How to get tsc to Resolve Absolute Paths when Importing Modules using baseUrl?
body: <p>Consider a simple typescript project with the following directory structure:</p>
  
  <pre><code>|   package.json
  |   tsconfig.json
  |               
  \---src
      |   app.ts
      |   
      \---foobar
              Foo.ts
              Bar.ts
  </code></pre>
  
  <p><code>tsconfig.json</code> has been configured to have <code>./src/</code> be the <code>baseUrl</code>.</p>
  
  <pre><code>{
      "compilerOptions": {
          "module": "commonjs",
          "target": "es6",
          "noImplicitAny": true,
          "removeComments": true,
          "preserveConstEnums": true,
          "outDir": "./dist/",
          "baseUrl": "./src/"
      },
      "include": [
          "./src/**/*"
      ],
      "exclude": [
          "node_modules"
      ]
  }
  </code></pre>
  
  <p>Now suppose we want to import <code>Foo</code> in <code>Bar.ts</code>. My understanding is that by setting the <code>baseUrl</code>, we can now use absolute paths to import modules</p>
  
  <pre><code>import { Foo } from 'foobar/Foo'
  </code></pre>
  
  <p>as opposed to relative paths</p>
  
  <pre><code>import { Foo } from './Foo'
  </code></pre>
  
  <p>If my understanding is correct, the typescript compiler should be able to automatically resolve <code>foobar/Foo</code> to <code>./Foo</code> when compiling <code>Bar.ts</code>.</p>
  
  <pre><code>import { Foo } from 'foobar/Foo';
  
  export class Bar {
    foo: Foo;
  
    constructor(num: number) {
      this.foo = new Foo(num);
    }
  }
  </code></pre>
  
  <p>Running <code>tsc</code> compiles without errors. Yet, when we actually look at the compiled <code>Bar.js</code>, we would see that the path has not been resolved correctly, which would give us a <em>Cannot find module</em> error if we were to run it.</p>
  
  <pre><code>"use strict";
  const Foo_1 = require("foobar/Foo");
  class Bar {
      constructor(num) {
          this.foo = new Foo_1.Foo(num);
      }
  }
  exports.Bar = Bar;
  </code></pre>
  
  <p><strong>So my question is: How can I get <code>tsc</code> to correctly resolve the absolute paths when importing modules using <code>baseUrl</code>? Or if this is not something that can be done, what is the purpose of <code>baseUrl</code> then?</strong></p>