<p dir="auto">Sometimes it happens so that some code logically belongs in one module, but there is just too much of it to put in one file. For example, here is my use case:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// base.ts
export interface SomeCoreType { ... }

export interface MyStandardAjaxResponse { ... }
export function doAjax( url: string, onSuccess: (r: MyStandardAjaxResponse) =&gt; void ) { ... }

export interface User { ... }
export function isUserOk( u: User ) { return ... }
// and so on"><pre class="notranslate"><code class="notranslate">// base.ts
export interface SomeCoreType { ... }

export interface MyStandardAjaxResponse { ... }
export function doAjax( url: string, onSuccess: (r: MyStandardAjaxResponse) =&gt; void ) { ... }

export interface User { ... }
export function isUserOk( u: User ) { return ... }
// and so on
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// customer.ts
import b = module( &quot;./base.ts&quot; );

export class Customer {
    constructor( id: number, someArg: b.SomeCoreType ) {
        b.doAjax( '/api/getCustomer', r =&gt; this.loadData( r ) );
    }

    loadData( r: b.MyStandardAjaxResponse ) { ... }
}
// and so on"><pre class="notranslate"><code class="notranslate">// customer.ts
import b = module( "./base.ts" );

export class Customer {
    constructor( id: number, someArg: b.SomeCoreType ) {
        b.doAjax( '/api/getCustomer', r =&gt; this.loadData( r ) );
    }

    loadData( r: b.MyStandardAjaxResponse ) { ... }
}
// and so on
</code></pre></div>
<p dir="auto">Over time, that <strong>base.ts</strong> file tends to grow with all kinds of enums, utility functions, common types, etc. At some point, it becomes so large that I want to partition it across several files. For example, I'd like to extract <strong>SomeCoreType</strong> into its own module <strong>coreType.ts</strong>, then extract <strong>MyStandardAjaxResponse</strong> and <strong>doAjax</strong> into <strong>ajax.ts</strong>, and extract <strong>User</strong> and <strong>isUserOk</strong> into <strong>user.ts</strong>. Just for my sanity's sake. Makes sense?</p>
<p dir="auto">But if I do that, I'll have to import a gazillion of modules every time.<br>
So my next logical step - consolidate them all back into base.ts:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// base.ts
import _coreType = module(&quot;./coreType&quot;);
export var CoreType = _coreType;

import _ajax = module(&quot;./ajax&quot;);
export var Ajax = _ajax;

import _user = module(&quot;./user&quot;);
export var User = _user;
// and so on"><pre class="notranslate"><code class="notranslate">// base.ts
import _coreType = module("./coreType");
export var CoreType = _coreType;

import _ajax = module("./ajax");
export var Ajax = _ajax;

import _user = module("./user");
export var User = _user;
// and so on
</code></pre></div>
<p dir="auto">That's better. Now I only have to import base.ts.<br>
However, I still have to write <strong>b.Ajax.doAjax</strong> instead of just <strong>b.doAjax</strong>. That's inconvenient.<br>
But an even bigger issue is that now I can't use interfaces declared in those modules. TypeScript just doesn't pick them up.</p>
<p dir="auto">What I'd like to be able to do is something like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import Ajax = module(&quot;./ajax&quot;);
export Ajax.*;"><pre class="notranslate"><code class="notranslate">import Ajax = module("./ajax");
export Ajax.*;
</code></pre></div>
<p dir="auto">Or, perhaps, the infamous <strong>export import</strong>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="export import Ajax = module(&quot;./ajax&quot;);"><pre class="notranslate"><code class="notranslate">export import Ajax = module("./ajax");
</code></pre></div>
<p dir="auto">Or, maybe, something like:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="reexport module(&quot;./ajax&quot;);"><pre class="notranslate"><code class="notranslate">reexport module("./ajax");
</code></pre></div>
<p dir="auto">And the output code could look something like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="define(['module', 'exports', './ajax'], function(module, exports, __ajax__) {
    for( var k in __ajax__ ) exports[k] = __ajax__[k];
});"><pre class="notranslate"><code class="notranslate">define(['module', 'exports', './ajax'], function(module, exports, __ajax__) {
    for( var k in __ajax__ ) exports[k] = __ajax__[k];
});
</code></pre></div>
<p dir="auto">Support compiling multiple input .ts files into one external module.</p>
<p dir="auto">Need to determine exactly how the module boundaries are defined when doing this.</p>