<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var a = [1, 'abc'] as [number, string];

var [b, c] = a;
[a].forEach(([d, e]) =&gt; {
    alert(d);
    alert(e);
});"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-s">'abc'</span><span class="pl-kos">]</span> <span class="pl-s1">as</span> <span class="pl-kos">[</span><span class="pl-s1">number</span><span class="pl-kos">,</span> <span class="pl-s1">string</span><span class="pl-kos">]</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-kos">[</span><span class="pl-s1">b</span><span class="pl-kos">,</span> <span class="pl-s1">c</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">a</span><span class="pl-kos">;</span>
<span class="pl-kos">[</span><span class="pl-s1">a</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">forEach</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-s1">d</span><span class="pl-kos">,</span> <span class="pl-s1">e</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s1">d</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-en">alert</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">There's something amiss with the typing in the above code snippet. TypeScript can figure out that <code class="notranslate">b</code> is a <code class="notranslate">number</code> and <code class="notranslate">c</code> is a <code class="notranslate">string</code>, it can even figure out that the <code class="notranslate">callbackFn</code> of my <code class="notranslate">forEach</code> is a <code class="notranslate">(value: [number, string], index: number, ...) =&gt; void</code>, but it says <code class="notranslate">d</code> and <code class="notranslate">e</code> are <code class="notranslate">any</code>. I'd have expected it to also know that these are <code class="notranslate">number</code> and <code class="notranslate">string</code> respectively.</p>
<p dir="auto">Paste this snippet in the <a href="http://www.typescriptlang.org/Playground" rel="nofollow">playground</a>:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const result = [{ foo: 'hello' }]
    .map(({ foo }) =&gt; foo)
    .map(foo =&gt; foo);"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span><span class="pl-kos">{</span> <span class="pl-c1">foo</span>: <span class="pl-s">'hello'</span> <span class="pl-kos">}</span><span class="pl-kos">]</span>
    <span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">{</span> foo <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">foo</span><span class="pl-kos">)</span>
    <span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-s1">foo</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">foo</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">If you hover over <code class="notranslate">foo</code> in the first <code class="notranslate">map()</code> call, you'll notice that its type is <code class="notranslate">any</code> (should be <code class="notranslate">string</code>).</p>
<p dir="auto">The type of <code class="notranslate">result</code> is correctly inferred to be <code class="notranslate">string[]</code>, though. It just seems that there is no type information for destructured function parameters.</p>