<p dir="auto"><em>From @voxking on March 14, 2016 23:12</em></p>
<ul dir="auto">
<li>VSCode Version: 0.10.10</li>
<li>OS Version: Windows 10</li>
</ul>
<p dir="auto">Typescript says things are duplicate when i move a file around.<br>
My guess is that the location of the file is not updated in the typescript service properly because when i restart VSCode it fixes itself but still its annoying to have to restart the editor.</p>
<p dir="auto">Steps to Reproduce:</p>
<ol dir="auto">
<li>get a large typescript code base like react.d.ts or something similar</li>
<li>move it</li>
<li>watch it happen</li>
</ol>
<p dir="auto"><em>Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="140822363" data-permission-text="Title is private" data-url="https://github.com/microsoft/vscode/issues/4211" data-hovercard-type="issue" data-hovercard-url="/microsoft/vscode/issues/4211/hovercard" href="https://github.com/microsoft/vscode/issues/4211">microsoft/vscode#4211</a></em></p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">If the version number were in the sources, i could answer this. bower says it's 1.8.x</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="// this is compiled JS code from some random bit of ts...
    var __metadata = (this &amp;&amp; this.__metadata) || function (k, v) {
        if (typeof Reflect === &quot;object&quot; &amp;&amp; typeof Reflect.metadata === &quot;function&quot;) return Reflect.metadata(k, v);
    };"><pre class="notranslate"><span class="pl-c">// this is compiled JS code from some random bit of ts...</span>
    <span class="pl-k">var</span> <span class="pl-s1">__metadata</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-smi">this</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">__metadata</span><span class="pl-kos">)</span> <span class="pl-c1">||</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">k</span><span class="pl-kos">,</span> <span class="pl-s1">v</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-k">typeof</span> <span class="pl-smi">Reflect</span> <span class="pl-c1">===</span> <span class="pl-s">"object"</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-k">typeof</span> <span class="pl-smi">Reflect</span><span class="pl-kos">.</span><span class="pl-c1">metadata</span> <span class="pl-c1">===</span> <span class="pl-s">"function"</span><span class="pl-kos">)</span> <span class="pl-k">return</span> <span class="pl-smi">Reflect</span><span class="pl-kos">.</span><span class="pl-en">metadata</span><span class="pl-kos">(</span><span class="pl-s1">k</span><span class="pl-kos">,</span> <span class="pl-s1">v</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"><strong>Expected behavior:</strong></p>
<p dir="auto">typeof ... === "object" is insufficient for such checks because of this JS quirk:</p>
<p dir="auto">(typeof null === "object")</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<p dir="auto">Such uses should include a null/falsy check:</p>
<p dir="auto">if(Reflect &amp;&amp; typeof Reflect==="object" &amp;&amp; ...)</p>
<p dir="auto">Update: as Daniel points out, the typeof check needs to come first:</p>
<p dir="auto">if(typeof Reflect==="object" &amp;&amp; Reflect &amp;&amp; ...)</p>
<p dir="auto">because typeof special-cases the handling of undefined symbols (as opposed to those when the undefined value).</p>