<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.0.10 &amp; nightly (1.9.0-dev.20160601)</p>
<p dir="auto"><strong>Code</strong></p>
<p dir="auto">Small example project here: <a href="https://github.com/unindented/ts-webpack-example">https://github.com/unindented/ts-webpack-example</a></p>
<p dir="auto">Project has the following layout:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=".
├── app
│   ├── index.css
│   ├── index.html
│   └── index.ts
├── components
│   ├── button
│   │   ├── index.css
│   │   ├── index.html
│   │   └── index.ts
│   └── counter
│       ├── index.css
│       ├── index.html
│       └── index.ts
├── package.json
├── shared
│   ├── backbone_base_view.ts
│   ├── backbone_with_default_render.ts
│   └── backbone_with_subviews.ts
└── tsconfig.json"><pre class="notranslate"><code class="notranslate">.
├── app
│   ├── index.css
│   ├── index.html
│   └── index.ts
├── components
│   ├── button
│   │   ├── index.css
│   │   ├── index.html
│   │   └── index.ts
│   └── counter
│       ├── index.css
│       ├── index.html
│       └── index.ts
├── package.json
├── shared
│   ├── backbone_base_view.ts
│   ├── backbone_with_default_render.ts
│   └── backbone_with_subviews.ts
└── tsconfig.json
</code></pre></div>
<p dir="auto"><code class="notranslate">tsconfig.json</code> has the following options:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;compilerOptions&quot;: {
    &quot;target&quot;: &quot;es5&quot;,
    &quot;module&quot;: &quot;commonjs&quot;,
    &quot;noImplicitAny&quot;: false,
    &quot;removeComments&quot;: false,
    &quot;preserveConstEnums&quot;: true,
    &quot;sourceMap&quot;: true,
    &quot;outDir&quot;: &quot;dist&quot;
  },
  &quot;exclude&quot;: [
    &quot;dist&quot;,
    &quot;node_modules&quot;
  ]
}"><pre class="notranslate">{
  <span class="pl-ent">"compilerOptions"</span>: {
    <span class="pl-ent">"target"</span>: <span class="pl-s"><span class="pl-pds">"</span>es5<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"module"</span>: <span class="pl-s"><span class="pl-pds">"</span>commonjs<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"noImplicitAny"</span>: <span class="pl-c1">false</span>,
    <span class="pl-ent">"removeComments"</span>: <span class="pl-c1">false</span>,
    <span class="pl-ent">"preserveConstEnums"</span>: <span class="pl-c1">true</span>,
    <span class="pl-ent">"sourceMap"</span>: <span class="pl-c1">true</span>,
    <span class="pl-ent">"outDir"</span>: <span class="pl-s"><span class="pl-pds">"</span>dist<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"exclude"</span>: [
    <span class="pl-s"><span class="pl-pds">"</span>dist<span class="pl-pds">"</span></span>,
    <span class="pl-s"><span class="pl-pds">"</span>node_modules<span class="pl-pds">"</span></span>
  ]
}</pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">I'd expect <code class="notranslate">import</code>s like this one to work:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import Counter from 'components/counter/index';"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-smi">Counter</span> <span class="pl-k">from</span> <span class="pl-s">'components/counter/index'</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">I get <code class="notranslate">TS2307</code> errors:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="app/index.ts(1,21): error TS2307: Cannot find module 'components/counter/index'.
components/button/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'.
components/button/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'.
components/counter/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'.
components/counter/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'.
components/counter/index.ts(4,27): error TS2307: Cannot find module 'shared/backbone_with_subviews'.
components/counter/index.ts(5,20): error TS2307: Cannot find module 'components/button/index'."><pre class="notranslate"><code class="notranslate">app/index.ts(1,21): error TS2307: Cannot find module 'components/counter/index'.
components/button/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'.
components/button/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'.
components/counter/index.ts(2,22): error TS2307: Cannot find module 'shared/backbone_base_view'.
components/counter/index.ts(3,25): error TS2307: Cannot find module 'shared/backbone_with_default_render'.
components/counter/index.ts(4,27): error TS2307: Cannot find module 'shared/backbone_with_subviews'.
components/counter/index.ts(5,20): error TS2307: Cannot find module 'components/button/index'.
</code></pre></div>
<p dir="auto">However, if I change <code class="notranslate">module</code> to <code class="notranslate">amd</code>, things do work.</p>
<p dir="auto">If this is intentional, is there a way to have <code class="notranslate">commonjs</code> be able to resolve these kinds of <em>"absolute"</em> paths?</p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">This is reproducible both in VSCode 1.0 and in the playground (<a href="https://www.typescriptlang.org/play/#src=interface%20A%20%7B%0D%0A%09x%3A%20number%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20B%20%7B%0D%0A%09x%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Aconst%20c%3A%20A%20%7C%20B%20%3D%20%7B%20x%3A%201%20%7C%7C%20%22a%22%20%7D%3B%0D%0A%0D%0Aconst%20d%3A%20A%20%7C%20B%20%3D%20%7B%20x%3A%201%20%7D%20%7C%7C%20%7B%20x%3A%20%22a%22%20%7D%3B%0D%0A" rel="nofollow">https://www.typescriptlang.org/play/#src=...</a>)</p>
<p dir="auto"><strong>Code</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="interface A {
    x: number;
}

interface B {
    x: string;
}

const c: A | B = { x: 1 || &quot;a&quot; };

const d: A | B = { x: 1 } || { x: &quot;a&quot; };
"><pre class="notranslate"><span class="pl-k">interface</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span>
    <span class="pl-c1">x</span>: <span class="pl-smi">number</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">B</span> <span class="pl-kos">{</span>
    <span class="pl-c1">x</span>: <span class="pl-smi">string</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">const</span> <span class="pl-s1">c</span>: <span class="pl-smi">A</span> <span class="pl-c1">|</span> <span class="pl-smi">B</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-c1">x</span>: <span class="pl-c1">1</span> <span class="pl-c1">||</span> <span class="pl-s">"a"</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-s1">d</span>: <span class="pl-smi">A</span> <span class="pl-c1">|</span> <span class="pl-smi">B</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-c1">x</span>: <span class="pl-c1">1</span> <span class="pl-kos">}</span> <span class="pl-c1">||</span> <span class="pl-kos">{</span> <span class="pl-c1">x</span>: <span class="pl-s">"a"</span> <span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong><br>
Both <code class="notranslate">c</code> and <code class="notranslate">d</code> should be fine</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
TypeScript reports this error for the <code class="notranslate">const c: A | B = { x: 1 || "a" };</code> statement:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Type '{ x: number | string; }' is not assignable to type 'A | B'.
  Type '{ x: number | string; }' is not assignable to type 'B'.
    Types of property 'x' are incompatible.
      Type 'number | string' is not assignable to type 'string'.
        Type 'number' is not assignable to type 'string'."><pre class="notranslate"><code class="notranslate">Type '{ x: number | string; }' is not assignable to type 'A | B'.
  Type '{ x: number | string; }' is not assignable to type 'B'.
    Types of property 'x' are incompatible.
      Type 'number | string' is not assignable to type 'string'.
        Type 'number' is not assignable to type 'string'.
</code></pre></div>