<p dir="auto">This <em>may</em> be a duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="138196002" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/7368" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/7368/hovercard" href="https://github.com/microsoft/TypeScript/issues/7368">#7368</a>, but since that bug involves (external) modules and this one just involves namespaces (or internal modules), I figured I would report it.</p>
<p dir="auto">Given a namespace <code class="notranslate">X</code>, if you have <code class="notranslate">import Y = X</code> and also declare a variable <code class="notranslate">X</code>, TypeScript thinks that <code class="notranslate">Y</code> is the variable <code class="notranslate">X</code>. For example, my angular.d.ts has:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare var angular: angular.IAngularStatic;
import ng = angular;
declare namespace angular {
..."><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">var</span> <span class="pl-s1">angular</span>: <span class="pl-s1">angular</span><span class="pl-kos">.</span><span class="pl-smi">IAngularStatic</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">ng</span> <span class="pl-c1">=</span> <span class="pl-s1">angular</span><span class="pl-kos">;</span>
<span class="pl-k">declare</span> <span class="pl-k">namespace</span> <span class="pl-s1">angular</span> <span class="pl-kos">{</span>
...</pre></div>
<p dir="auto">Now when I call a member of IAngularStatic on <code class="notranslate">ng</code>, I get no compile error, e.g.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let copy = ng.copy(item);"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">copy</span> <span class="pl-c1">=</span> <span class="pl-s1">ng</span><span class="pl-kos">.</span><span class="pl-en">copy</span><span class="pl-kos">(</span><span class="pl-s1">item</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">compiles fine, but of course I get an error at runtime because <code class="notranslate">ng</code> does not exist.</p>
<p dir="auto">This is with TypeScript 1.8</p>
<p dir="auto">Hi there,</p>
<p dir="auto">Not sure whether this has been already mentioned before (I would be surpirsed if it never was)... Wouldn't it be a good idea to name arrow functions, which is what apparently ES6 does?. Think about the benefits of this in the stacktrace. It's quite useful to have a "named" function in there, instead of an anonymous one ;-)</p>
<p dir="auto">So, this:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const double = x =&gt; x * 2;"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-en">double</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">x</span> <span class="pl-c1">*</span> <span class="pl-c1">2</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">would be transpiled down to:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var double = function double(x) {
  return x * 2;
};"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-en">double</span> <span class="pl-c1">=</span> <span class="pl-k">function</span> <span class="pl-en">double</span><span class="pl-kos">(</span><span class="pl-s1">x</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">return</span> <span class="pl-s1">x</span> <span class="pl-c1">*</span> <span class="pl-c1">2</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Just to mention that Babel does it like that ;-)</p>
<p dir="auto">Thanks.</p>