<p dir="auto">Maybe this is actually an issue with Visual Studio, but when I create a typescript project and  provoke a build error, I'll get the error message twice in the Error List - one time from IntelliSense and one time from the compiler.</p>
<p dir="auto">And it looks like - when doing something similar in C# - the error messages are merged when they are identical. I do not know, if that is actually how it works, but it would explain the behavior, because the message from the TypeScript compiler is prefixed with "Build: " and for some strange reason the error code does not show up in the the list either, so the messages are not identical.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/299575/9812015/d5281c68-587a-11e5-817a-7c153a23c5ef.png"><img src="https://cloud.githubusercontent.com/assets/299575/9812015/d5281c68-587a-11e5-817a-7c153a23c5ef.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">If that's not the case, the question remains: why are errors shown twice for TypeScript, but not for C#? :)</p>
<p dir="auto">Hi gyus,<br>
I could not find duplicate so I am posting here.</p>
<p dir="auto"><strong>TypeScript Version:</strong> <code class="notranslate">1.8.9</code><br>
Target: <code class="notranslate">es5</code></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) {
  console.log(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-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</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>Actual emit:</strong></p>
<div class="highlight highlight-source-js 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 _i = 0, myMap_1 = myMap; _i &lt; myMap_1.length; _i++) {
    var _a = myMap_1[_i], key = _a[0], value = _a[1];
    console.log(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-v">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-s1">_i</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-s1">myMap_1</span> <span class="pl-c1">=</span> <span class="pl-s1">myMap</span><span class="pl-kos">;</span> <span class="pl-s1">_i</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">myMap_1</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">;</span> <span class="pl-s1">_i</span><span class="pl-c1">++</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">var</span> <span class="pl-s1">_a</span> <span class="pl-c1">=</span> <span class="pl-s1">myMap_1</span><span class="pl-kos">[</span><span class="pl-s1">_i</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-s1">key</span> <span class="pl-c1">=</span> <span class="pl-s1">_a</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-s1">value</span> <span class="pl-c1">=</span> <span class="pl-s1">_a</span><span class="pl-kos">[</span><span class="pl-c1">1</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-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">The problem is that <code class="notranslate">Map</code>(and <code class="notranslate">Set</code> too) instance does not have <code class="notranslate">length</code> property, instead it has <code class="notranslate">size</code> property. As result loop does not traverse</p>
<p dir="auto"><a href="http://www.typescriptlang.org/play/index.html#src=var%20myMap%20%3D%20new%20Map%28%29%3B%0D%0AmyMap.set%280%2C%20%22zero%22%29%3B%0D%0AmyMap.set%281%2C%20%22one%22%29%3B%0D%0Afor%20%28var%20%5Bkey%2C%20value%5D%20of%20myMap%29%20%7B%0D%0A%20%20console.log%28key%20%2B%20%22%20%3D%20%22%20%2B%20value%29%3B%0D%0A%7D" rel="nofollow">Playground</a></p>