<p dir="auto">TypeScript compiler hangs for me and does not complete compilation within 5 minutes on a 50 KB source file. To reproduce, run on this input file:</p>
<p dir="auto"><a href="https://raw.githubusercontent.com/Tachyus/gluon/master/src/Gluon.Client/Gluon.ts" rel="nofollow">https://raw.githubusercontent.com/Tachyus/gluon/master/src/Gluon.Client/Gluon.ts</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Platform: Windows 10 64-bit

tsc --version
message TS6029: Version 1.7.3

node --version
v5.2.0"><pre class="notranslate"><code class="notranslate">Platform: Windows 10 64-bit

tsc --version
message TS6029: Version 1.7.3

node --version
v5.2.0
</code></pre></div>
<p dir="auto">This is the same code as what originally prompted <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="72573486" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/2997" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/2997/hovercard" href="https://github.com/microsoft/TypeScript/issues/2997">#2997</a></p>
<p dir="auto">While it isn't crashing because of infinite loops any more, it <em>has</em> become very slow with 1.7. If I pause it in the debugger I see the following stack repeating many times.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="inferFromTypes [tsc.js] Line 15334  JavaScript
inferFromTypes [tsc.js] Line 15314  JavaScript
inferFromTypes [tsc.js] Line 15301  JavaScript
inferFromProperties [tsc.js] Line 15350 JavaScript
inferFromTypes [tsc.js] Line 15334  JavaScript
inferFromTypes [tsc.js] Line 15314  JavaScript
inferFromTypes [tsc.js] Line 15301  JavaScript
inferFromIndexTypes [tsc.js] Line 15380 JavaScript
inferFromTypes [tsc.js] Line 15337  JavaScript
inferFromProperties [tsc.js] Line 15350 JavaScript"><pre class="notranslate"><code class="notranslate">inferFromTypes [tsc.js] Line 15334  JavaScript
inferFromTypes [tsc.js] Line 15314  JavaScript
inferFromTypes [tsc.js] Line 15301  JavaScript
inferFromProperties [tsc.js] Line 15350 JavaScript
inferFromTypes [tsc.js] Line 15334  JavaScript
inferFromTypes [tsc.js] Line 15314  JavaScript
inferFromTypes [tsc.js] Line 15301  JavaScript
inferFromIndexTypes [tsc.js] Line 15380 JavaScript
inferFromTypes [tsc.js] Line 15337  JavaScript
inferFromProperties [tsc.js] Line 15350 JavaScript
</code></pre></div>
<p dir="auto">Reduced test case:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Module {
    public members: { [name: string]: FFunction | Property };
}

class Namespace {
    public members: { [name: string]: Class | Enum };
}

class Class {
    public parent: Module | Namespace;

    public members: { [name: string]: Property | FFunction };
}

class Interface {
    public members: { [name: string]: Property | FFunction };
}

class FFunction {
    public parent: Module | Namespace | Class | Interface; // (1)
}

class Property {
    public parent: Module | Namespace | Class | Interface; // (2)
}

class Enum {
    public parent: Module | Namespace;

    public members: EnumMember[];
}

class EnumMember {
    public parent: Enum;
}

var members: (Property | FFunction)[];
members.map(member =&gt; &quot;&quot;);"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">Module</span> <span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-c1">members</span>: <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">FFunction</span> <span class="pl-c1">|</span> <span class="pl-smi">Property</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">Namespace</span> <span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-c1">members</span>: <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">Class</span> <span class="pl-c1">|</span> <span class="pl-smi">Enum</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">Class</span> <span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-c1">parent</span>: <span class="pl-smi">Module</span> <span class="pl-c1">|</span> <span class="pl-smi">Namespace</span><span class="pl-kos">;</span>

    <span class="pl-k">public</span> <span class="pl-c1">members</span>: <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">Property</span> <span class="pl-c1">|</span> <span class="pl-smi">FFunction</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">Interface</span> <span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-c1">members</span>: <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">Property</span> <span class="pl-c1">|</span> <span class="pl-smi">FFunction</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">FFunction</span> <span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-c1">parent</span>: <span class="pl-smi">Module</span> <span class="pl-c1">|</span> <span class="pl-smi">Namespace</span> <span class="pl-c1">|</span> <span class="pl-smi">Class</span> <span class="pl-c1">|</span> <span class="pl-smi">Interface</span><span class="pl-kos">;</span> <span class="pl-c">// (1)</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">Property</span> <span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-c1">parent</span>: <span class="pl-smi">Module</span> <span class="pl-c1">|</span> <span class="pl-smi">Namespace</span> <span class="pl-c1">|</span> <span class="pl-smi">Class</span> <span class="pl-c1">|</span> <span class="pl-smi">Interface</span><span class="pl-kos">;</span> <span class="pl-c">// (2)</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">Enum</span> <span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-c1">parent</span>: <span class="pl-smi">Module</span> <span class="pl-c1">|</span> <span class="pl-smi">Namespace</span><span class="pl-kos">;</span>

    <span class="pl-k">public</span> <span class="pl-c1">members</span>: <span class="pl-smi">EnumMember</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">class</span> <span class="pl-smi">EnumMember</span> <span class="pl-kos">{</span>
    <span class="pl-k">public</span> <span class="pl-c1">parent</span>: <span class="pl-smi">Enum</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">var</span> <span class="pl-s1">members</span>: <span class="pl-kos">(</span><span class="pl-smi">Property</span> <span class="pl-c1">|</span> <span class="pl-smi">FFunction</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-s1">members</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-s1">member</span> <span class="pl-c1">=&gt;</span> <span class="pl-s">""</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Compile with <code class="notranslate">tsc foo.ts</code> on node 4.2.2 x64 on Windows 7.</p>
<p dir="auto">This takes ~18s on my machine. If I remove <code class="notranslate">Module</code> from the union type at (1), it drops to ~12s. Removing <code class="notranslate">Module</code> at (2) drops it to ~6s. And so on.</p>
<p dir="auto">The original code is at <a href="https://github.com/Arnavion/libjass/blob/82f3706/build/typescript/ast.ts">https://github.com/Arnavion/libjass/blob/82f3706/build/typescript/ast.ts</a> which has a much more complicated forest of types. It's been compiling for 5 minutes now, whereas it took ~2s with 1.6</p>