<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.9</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="// A self-contained demonstration of the problem follows...
&lt;div&gt;{integer}&lt;span&gt;,{fraction}&lt;/span&gt;&lt;/div&gt;"><pre class="notranslate"><span class="pl-c">// A self-contained demonstration of the problem follows...</span>
<span class="pl-kos">&lt;</span><span class="pl-smi">div</span><span class="pl-kos">&gt;</span><span class="pl-kos">{</span>integer<span class="pl-kos">}</span><span class="pl-kos">&lt;</span><span class="pl-smi">span</span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span><span class="pl-kos">{</span>fraction<span class="pl-kos">}</span><span class="pl-c1">&lt;</span><span class="pl-pds"><span class="pl-c1">/</span>span&gt;&lt;<span class="pl-c1">/</span>div</span><span class="pl-c1">&gt;</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong><br>
Same as in example</p>
<p dir="auto"><strong>Actual behavior:</strong></p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;div&gt;{integer}&lt;span&gt;, {fraction}&lt;/span&gt;&lt;/div&gt;"><pre class="notranslate"><span class="pl-kos">&lt;</span><span class="pl-smi">div</span><span class="pl-kos">&gt;</span><span class="pl-kos">{</span>integer<span class="pl-kos">}</span><span class="pl-kos">&lt;</span><span class="pl-smi">span</span><span class="pl-kos">&gt;</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>fraction<span class="pl-kos">}</span><span class="pl-c1">&lt;</span><span class="pl-pds"><span class="pl-c1">/</span>span&gt;&lt;<span class="pl-c1">/</span>div</span><span class="pl-c1">&gt;</span></pre></div>
<p dir="auto">Formatter inserts space after the comma inside tags</p>
<p dir="auto"><strong>TypeScript Version:</strong><br>
1.8.9</p>
<p dir="auto">I should first mention that i using Typescript inside <a href="https://github.com/appcelerator/titanium_mobile">Titanium Mobile Framework</a>. Which means no browser environment.</p>
<p dir="auto">It also means that sometimes (<a href="http://docs.appcelerator.com/titanium/3.0/#!/guide/CommonJS_Modules_in_Titanium" rel="nofollow">compiled library modules</a>) to do <code class="notranslate">require('test')</code> i actually have to write <code class="notranslate">require('mymodule/test')</code></p>
<p dir="auto">Now my issue is not about the actual require but about the "imported definition" that goes with it.<br>
For example if i have this</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//test.ts
class A {
   toString(){return &quot;test&quot;;}
}
export = A"><pre class="notranslate"><span class="pl-c">//test.ts</span>
<span class="pl-k">class</span> <span class="pl-smi">A</span> <span class="pl-kos">{</span>
   <span class="pl-en">toString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">{</span><span class="pl-k">return</span> <span class="pl-s">"test"</span><span class="pl-kos">;</span><span class="pl-kos">}</span>
<span class="pl-kos">}</span>
<span class="pl-k">export</span> <span class="pl-c1">=</span> <span class="pl-smi">A</span></pre></div>
<p dir="auto">Now i want to use that class in another ts file. If i do this</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import A = require('test');"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-smi">A</span> <span class="pl-c1">=</span> require<span class="pl-kos">(</span><span class="pl-s">'test'</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">it won't work because i actually have to write</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import A = require('mymodule/test');"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-smi">A</span> <span class="pl-c1">=</span> require<span class="pl-kos">(</span><span class="pl-s">'mymodule/test'</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">but then the compiler wont find <code class="notranslate">A</code> declaration because it wont find the <code class="notranslate">test.ts</code> file</p>
<p dir="auto">Another use case is when we actually hide the <code class="notranslate">require</code>. For example i have that class</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class Loader {
   __creators = {}
   __constructors = {}
   registerCreator(name: string) {
      this.__creators[name] = (...args) =&gt; {
          if (!this.__constructors[name]) {
               this.__constructors[name] = require(name);
          }
          return this.__constructors[name].call(this, args);
      }
   }
   create(name:string, ...args) {
       return this.__creators[name](args);
   }
}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">Loader</span> <span class="pl-kos">{</span>
   <span class="pl-c1">__creators</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
   <span class="pl-c1">__constructors</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
   <span class="pl-en">registerCreator</span><span class="pl-kos">(</span><span class="pl-s1">name</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">__creators</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span>...<span class="pl-s1">args</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
          <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-c1">!</span><span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">__constructors</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
               <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">__constructors</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s1">name</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
          <span class="pl-kos">}</span>
          <span class="pl-k">return</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">__constructors</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span><span class="pl-smi">this</span><span class="pl-kos">,</span> <span class="pl-s1">args</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-kos">}</span>
   <span class="pl-kos">}</span>
   <span class="pl-en">create</span><span class="pl-kos">(</span><span class="pl-s1">name</span>:<span class="pl-smi">string</span><span class="pl-kos">,</span> ...<span class="pl-s1">args</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
       <span class="pl-k">return</span> <span class="pl-smi">this</span><span class="pl-kos">.</span><span class="pl-c1">__creators</span><span class="pl-kos">[</span><span class="pl-s1">name</span><span class="pl-kos">]</span><span class="pl-kos">(</span><span class="pl-s1">args</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">I am using that class to only <code class="notranslate">require</code>(which means load the js file) when needed.<br>
But because of that when i use <code class="notranslate">Loader.create</code> there is no way for me to cast the resulting object to <code class="notranslate">A</code> for example because i did not use <code class="notranslate">import</code></p>
<p dir="auto">Right now i solve that by creating an interface in a declaration file and then make my class implement that interface. But that's a real pain because i have to duplicate all my classes definitions (which are already generated for example in <code class="notranslate">test.d.ts</code></p>
<p dir="auto">So what i would need is a way to only import declaration. I am not sure of the form it could take.<br>
Maybe something like</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import declaration A from 'test';"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">declaration</span> <span class="pl-smi">A</span> <span class="pl-k">from</span> <span class="pl-s">'test'</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">or</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/// &lt;reference path=&quot;test.d.ts&quot; /&gt;  // i actually can't do this right now because test.d.ts is generated by the compiler"><pre class="notranslate"><span class="pl-c">/// &lt;reference path="test.d.ts" /&gt;  // i actually can't do this right now because test.d.ts is generated by the compiler</span></pre></div>
<p dir="auto">Or may be there is already a way to do this?</p>
<p dir="auto">Thanks a lot, love Typescript!</p>