<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.10</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="// A self-contained demonstration of the problem follows...
function bool_fun(value: string) : boolean {
    return value &amp;&amp; value == &quot;bug&quot;;
}

console.log(bool_fun(null)); // should log false or throw a compiler error, but logs null
console.log(bool_fun(&quot;false&quot;));
console.log(bool_fun(&quot;bug&quot;));"><pre class="notranslate"><span class="pl-c">// A self-contained demonstration of the problem follows...</span>
<span class="pl-k">function</span> <span class="pl-en">bool_fun</span><span class="pl-kos">(</span><span class="pl-s1">value</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span> : <span class="pl-smi">boolean</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-s1">value</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">value</span> <span class="pl-c1">==</span> <span class="pl-s">"bug"</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-en">bool_fun</span><span class="pl-kos">(</span><span class="pl-c1">null</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// should log false or throw a compiler error, but logs null</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-en">bool_fun</span><span class="pl-kos">(</span><span class="pl-s">"false"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-en">bool_fun</span><span class="pl-kos">(</span><span class="pl-s">"bug"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">A <code class="notranslate">boolean</code> value should always be <code class="notranslate">true</code> or <code class="notranslate">false</code>, but never <code class="notranslate">null</code> (even if it's a falsy value). This would break strict comparisons like <code class="notranslate">===</code>. The spec is also very clear: <a href="https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.2.2">https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.2.2</a></p>
<p dir="auto"><strong>Expected behavior:</strong><br>
Either we have a compiler error or the console prints:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="false
false
true"><pre class="notranslate"><code class="notranslate">false
false
true
</code></pre></div>
<p dir="auto"><strong>Actual behavior:</strong><br>
The console prints:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="null
false
true"><pre class="notranslate"><code class="notranslate">null
false
true
</code></pre></div>
<p dir="auto">This code does not end the compilation on Windows 7 using master branch of TypeScript.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ node built/local/tsc.js hang.ts"><pre class="notranslate"><code class="notranslate">$ node built/local/tsc.js hang.ts
</code></pre></div>
<p dir="auto">And VS2013 was hangup. <code class="notranslate">devenv.exe</code> consume memory about 3.5GB.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// hang.ts
interface LazyChain&lt;T&gt; extends LAZYCHAIN.Stream&lt;T&gt; {
}

interface LazyMonad&lt;T, M&gt; extends LAZYCHAIN.MonadStream&lt;T, M&gt; {
}

interface Array&lt;T&gt; extends LAZYCHAIN.StreamMethod&lt;T&gt; {
}

declare module LAZYCHAIN {

  interface Callback&lt;T, U, V&gt; {
    (value?: T, index?: number, array?: T[], env?: V): U
  }

  interface CallbackAsync&lt;T, U, V&gt; {
    (value?: T, index?: number, array?: T[], env?: V, deferred?): any
  }

  interface StreamMethod&lt;T&gt; {
    // lazy
    //  - basic
    lazy(onmessage: CallbackAsync&lt;T, T, {}&gt;): LazyChain&lt;T&gt;
    lazy(onmessage: CallbackAsync&lt;T, T, {}&gt;, sequential: boolean): LazyChain&lt;T[]&gt;
  }

  interface Stream&lt;T&gt; extends StreamMethod&lt;T&gt; {
    // pattern
    pattern(...patterns: Array&lt;[T|Function]|[T|Function, (...args: T[]) =&gt; T]|[T|Function, (...args: T[]) =&gt; boolean, (...args: T[]) =&gt; T]&gt;): LazyChain&lt;T&gt;
    // monad
    monad&lt;M&gt;(monad: Monad&lt;T, M&gt;, convert?: boolean): LazyMonad&lt;T, M&gt;
    monad&lt;M&gt;(monad: Monad&lt;T, M&gt;, type: T|((...args: any[]) =&gt; T)): LazyMonad&lt;T, M&gt;
    // array
    array(): T[]
  }

  interface MonadStream&lt;T, M&gt; {
    // pattern
    pattern(...patterns: Array&lt;[M]|[M, (...args: M[]) =&gt; M]|[M, (...args: M[]) =&gt; boolean, (...args: M[]) =&gt; M]&gt;): LazyMonad&lt;T, M&gt;
    // monadic
    monadic(...patterns: Array&lt;[M]|[M, (...args: T[]) =&gt; M]|[M, (...args: T[]) =&gt; boolean, (...args: T[]) =&gt; M]&gt;): LazyMonad&lt;T, M&gt;
    // lazy
    //  - basic
    lazy(onmessage: CallbackAsync&lt;M, M, {}&gt;): LazyMonad&lt;T, M&gt;
    lazy(onmessage: CallbackAsync&lt;M, M, {}&gt;, sequential: boolean): LazyMonad&lt;T, M[]&gt;
    // array
    array(): T[]
  }

  interface Monad&lt;T, M&gt; extends Monoid&lt;M&gt; {
    return(arg: T): M
    bind(m: M, f: (arg: T) =&gt; M): M
    fail?(arg: any): M
  }

  interface Monoid&lt;M&gt; {
    mempty?(): M
    mappend?(m1: M, m2: M): M
    mconcat?(ms: M[]): M
  }

}

function f&lt;T, U&gt;(): LazyChain&lt;T|U&gt; {
  return &lt;LazyChain&lt;T|T[]|U|U[]&gt;&gt;null;
}"><pre class="notranslate"><span class="pl-c">// hang.ts</span>
<span class="pl-k">interface</span> <span class="pl-smi">LazyChain</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span> <span class="pl-k">extends</span> <span class="pl-smi">LAZYCHAIN</span><span class="pl-kos">.</span><span class="pl-smi">Stream</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">LazyMonad</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-c1">&gt;</span> <span class="pl-k">extends</span> <span class="pl-smi">LAZYCHAIN</span><span class="pl-kos">.</span><span class="pl-smi">MonadStream</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span>

<span class="pl-k">interface</span> <span class="pl-smi">Array</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span> <span class="pl-k">extends</span> <span class="pl-smi">LAZYCHAIN</span><span class="pl-kos">.</span><span class="pl-smi">StreamMethod</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
<span class="pl-kos">}</span>

<span class="pl-k">declare</span> module <span class="pl-smi">LAZYCHAIN</span> <span class="pl-kos">{</span>

  <span class="pl-k">interface</span> <span class="pl-smi">Callback</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">U</span><span class="pl-kos">,</span> <span class="pl-smi">V</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-kos">(</span><span class="pl-s1">value</span>?: <span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-s1">index</span>?: <span class="pl-smi">number</span><span class="pl-kos">,</span> <span class="pl-s1">array</span>?: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-s1">env</span>?: <span class="pl-smi">V</span><span class="pl-kos">)</span>: <span class="pl-smi">U</span>
  <span class="pl-kos">}</span>

  <span class="pl-k">interface</span> <span class="pl-smi">CallbackAsync</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">U</span><span class="pl-kos">,</span> <span class="pl-smi">V</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-kos">(</span><span class="pl-s1">value</span>?: <span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-s1">index</span>?: <span class="pl-smi">number</span><span class="pl-kos">,</span> <span class="pl-s1">array</span>?: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-s1">env</span>?: <span class="pl-smi">V</span><span class="pl-kos">,</span> <span class="pl-s1">deferred</span>?<span class="pl-kos">)</span>: <span class="pl-smi">any</span>
  <span class="pl-kos">}</span>

  <span class="pl-k">interface</span> <span class="pl-smi">StreamMethod</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c">// lazy</span>
    <span class="pl-c">//  - basic</span>
    <span class="pl-c1">lazy</span><span class="pl-kos">(</span><span class="pl-s1">onmessage</span>: <span class="pl-smi">CallbackAsync</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyChain</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span>
    <span class="pl-c1">lazy</span><span class="pl-kos">(</span><span class="pl-s1">onmessage</span>: <span class="pl-smi">CallbackAsync</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span> <span class="pl-s1">sequential</span>: <span class="pl-smi">boolean</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyChain</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">&gt;</span>
  <span class="pl-kos">}</span>

  <span class="pl-k">interface</span> <span class="pl-smi">Stream</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">&gt;</span> <span class="pl-k">extends</span> <span class="pl-smi">StreamMethod</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c">// pattern</span>
    <span class="pl-c1">pattern</span><span class="pl-kos">(</span>...<span class="pl-s1">patterns</span>: <span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-kos">[</span><span class="pl-smi">T</span><span class="pl-c1">|</span><span class="pl-smi">Function</span><span class="pl-kos">]</span><span class="pl-c1">|</span><span class="pl-kos">[</span><span class="pl-smi">T</span><span class="pl-c1">|</span><span class="pl-smi">Function</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">T</span><span class="pl-kos">]</span><span class="pl-c1">|</span><span class="pl-kos">[</span><span class="pl-smi">T</span><span class="pl-c1">|</span><span class="pl-smi">Function</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">boolean</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">T</span><span class="pl-kos">]</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyChain</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span>
    <span class="pl-c">// monad</span>
    <span class="pl-c1">monad</span><span class="pl-c1">&lt;</span><span class="pl-smi">M</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">monad</span>: <span class="pl-smi">Monad</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span> <span class="pl-s1">convert</span>?: <span class="pl-smi">boolean</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyMonad</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">&gt;</span>
    <span class="pl-c1">monad</span><span class="pl-c1">&lt;</span><span class="pl-smi">M</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">monad</span>: <span class="pl-smi">Monad</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span> <span class="pl-s1">type</span>: <span class="pl-smi">T</span><span class="pl-c1">|</span><span class="pl-kos">(</span><span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">any</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">T</span><span class="pl-kos">)</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyMonad</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">&gt;</span>
    <span class="pl-c">// array</span>
    <span class="pl-c1">array</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span>
  <span class="pl-kos">}</span>

  <span class="pl-k">interface</span> <span class="pl-smi">MonadStream</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c">// pattern</span>
    <span class="pl-c1">pattern</span><span class="pl-kos">(</span>...<span class="pl-s1">patterns</span>: <span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-kos">[</span><span class="pl-smi">M</span><span class="pl-kos">]</span><span class="pl-c1">|</span><span class="pl-kos">[</span><span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">M</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">M</span><span class="pl-kos">]</span><span class="pl-c1">|</span><span class="pl-kos">[</span><span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">M</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">boolean</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">M</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">M</span><span class="pl-kos">]</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyMonad</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">&gt;</span>
    <span class="pl-c">// monadic</span>
    <span class="pl-c1">monadic</span><span class="pl-kos">(</span>...<span class="pl-s1">patterns</span>: <span class="pl-smi">Array</span><span class="pl-kos">&lt;</span><span class="pl-kos">[</span><span class="pl-smi">M</span><span class="pl-kos">]</span><span class="pl-c1">|</span><span class="pl-kos">[</span><span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">M</span><span class="pl-kos">]</span><span class="pl-c1">|</span><span class="pl-kos">[</span><span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">boolean</span><span class="pl-kos">,</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span>: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">M</span><span class="pl-kos">]</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyMonad</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">&gt;</span>
    <span class="pl-c">// lazy</span>
    <span class="pl-c">//  - basic</span>
    <span class="pl-c1">lazy</span><span class="pl-kos">(</span><span class="pl-s1">onmessage</span>: <span class="pl-smi">CallbackAsync</span><span class="pl-kos">&lt;</span><span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyMonad</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">&gt;</span>
    <span class="pl-c1">lazy</span><span class="pl-kos">(</span><span class="pl-s1">onmessage</span>: <span class="pl-smi">CallbackAsync</span><span class="pl-kos">&lt;</span><span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span> <span class="pl-s1">sequential</span>: <span class="pl-smi">boolean</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyMonad</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">&gt;</span>
    <span class="pl-c">// array</span>
    <span class="pl-c1">array</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span>
  <span class="pl-kos">}</span>

  <span class="pl-k">interface</span> <span class="pl-smi">Monad</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">M</span><span class="pl-c1">&gt;</span> <span class="pl-k">extends</span> <span class="pl-smi">Monoid</span><span class="pl-kos">&lt;</span><span class="pl-smi">M</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c1">return</span><span class="pl-kos">(</span><span class="pl-s1">arg</span>: <span class="pl-smi">T</span><span class="pl-kos">)</span>: <span class="pl-smi">M</span>
    <span class="pl-c1">bind</span><span class="pl-kos">(</span><span class="pl-s1">m</span>: <span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-s1">f</span>: <span class="pl-kos">(</span><span class="pl-s1">arg</span>: <span class="pl-smi">T</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">M</span><span class="pl-kos">)</span>: <span class="pl-smi">M</span>
    <span class="pl-c1">fail</span>?<span class="pl-kos">(</span><span class="pl-s1">arg</span>: <span class="pl-smi">any</span><span class="pl-kos">)</span>: <span class="pl-smi">M</span>
  <span class="pl-kos">}</span>

  <span class="pl-k">interface</span> <span class="pl-smi">Monoid</span><span class="pl-c1">&lt;</span><span class="pl-smi">M</span><span class="pl-c1">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c1">mempty</span>?<span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">M</span>
    <span class="pl-c1">mappend</span>?<span class="pl-kos">(</span><span class="pl-s1">m1</span>: <span class="pl-smi">M</span><span class="pl-kos">,</span> <span class="pl-s1">m2</span>: <span class="pl-smi">M</span><span class="pl-kos">)</span>: <span class="pl-smi">M</span>
    <span class="pl-c1">mconcat</span>?<span class="pl-kos">(</span><span class="pl-s1">ms</span>: <span class="pl-smi">M</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span>: <span class="pl-smi">M</span>
  <span class="pl-kos">}</span>

<span class="pl-kos">}</span>

<span class="pl-k">function</span> <span class="pl-en">f</span><span class="pl-c1">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">,</span> <span class="pl-smi">U</span><span class="pl-c1">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">LazyChain</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">|</span><span class="pl-smi">U</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-kos">&lt;</span><span class="pl-smi">LazyChain</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-c1">|</span><span class="pl-smi">T</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-c1">|</span><span class="pl-smi">U</span><span class="pl-c1">|</span><span class="pl-smi">U</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">&gt;</span><span class="pl-kos">&gt;</span><span class="pl-c1">null</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Update:<br>
I was able to get the error message after 3 hours.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ node built/local/tsc.js hang.ts
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory"><pre class="notranslate"><code class="notranslate">$ node built/local/tsc.js hang.ts
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
</code></pre></div>