<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">nightly (1.9.0-dev.20160430)</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="var myMap = new Map();
myMap.set(0, &quot;zero&quot;);
myMap.set(1, &quot;one&quot;);
for (var [key, value] of myMap) {
    alert(key + &quot; = &quot; + value);
}
"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">myMap</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-smi">Map</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">myMap</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-s">"zero"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">myMap</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-s">"one"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">var</span> <span class="pl-kos">[</span><span class="pl-s1">key</span><span class="pl-kos">,</span> <span class="pl-s1">value</span><span class="pl-kos">]</span> <span class="pl-k">of</span> <span class="pl-s1">myMap</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">key</span> <span class="pl-c1">+</span> <span class="pl-s">" = "</span> <span class="pl-c1">+</span> <span class="pl-s1">value</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong></p>
<p dir="auto">Possibility to do a iteration over map.</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">The compiler raises the follow error: <code class="notranslate">Type must have a '[Symbol.iterator]()' method that returns an iterator.</code></p>
<p dir="auto">The variable in a for-of loop contains <code class="notranslate">undefined</code> when the target is set to es6. For es5, everything works as expected.</p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">nightly (1.9.0-dev.20160428)</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="for (const x of [&quot;a&quot;, &quot;b&quot;]) {
    x.substring;
}"><pre class="notranslate"><span class="pl-k">for</span> <span class="pl-kos">(</span><span class="pl-k">const</span> <span class="pl-s1">x</span> <span class="pl-k">of</span> <span class="pl-kos">[</span><span class="pl-s">"a"</span><span class="pl-kos">,</span> <span class="pl-s">"b"</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-s1">x</span><span class="pl-kos">.</span><span class="pl-c1">substring</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">tsconfig.json:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;compilerOptions&quot;: {
        &quot;module&quot;: &quot;commonjs&quot;,
        &quot;target&quot;: &quot;es6&quot;,
        &quot;strictNullChecks&quot;: true
    }
}"><pre class="notranslate">{
    <span class="pl-ent">"compilerOptions"</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">"target"</span>: <span class="pl-s"><span class="pl-pds">"</span>es6<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"strictNullChecks"</span>: <span class="pl-c1">true</span>
    }
}</pre></div>
<p dir="auto"><strong>Expected behavior:</strong><br>
Type of <code class="notranslate">x</code> is <code class="notranslate">string</code> in the loop body, no compile error.</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
Type of <code class="notranslate">x</code> is <code class="notranslate">string | undefined</code>, which gives an error.</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ahejlsberg/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ahejlsberg">@ahejlsberg</a></p>