<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.8.10</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="new RegExp(/a/, &quot;g&quot;);"><pre class="notranslate"><span class="pl-k">new</span> <span class="pl-smi">RegExp</span><span class="pl-kos">(</span><span class="pl-pds"><span class="pl-c1">/</span>a<span class="pl-c1">/</span></span><span class="pl-kos">,</span> <span class="pl-s">"g"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong><br>
That code should be accepted by typescript</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
<code class="notranslate">Argument of type 'RegExp' is not assignable to parameter of type 'string'.</code></p>
<p dir="auto"><strong>TypeScript Version:</strong></p>
<p dir="auto">1.9.0-dev.20160522-1.0</p>
<p dir="auto"><strong>Code</strong></p>
<p dir="auto">Here's what I want to do:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import {isEmail} from 'marker.validators'"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-s1">isEmail</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'marker.validators'</span></pre></div>
<p dir="auto"><strong>Expected behavior:</strong><br>
For it to just work</p>
<p dir="auto"><strong>Actual behavior:</strong><br>
Submodules don't work that way</p>
<hr>
<p dir="auto">So currently I do this:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import {validators} from 'marker';

validators.isEmail('foo@bar.com');
// I want the `isEmail` symbol, without having to `const isEmail = validators.isEmail`"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span><span class="pl-s1">validators</span><span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'marker'</span><span class="pl-kos">;</span>

<span class="pl-s1">validators</span><span class="pl-kos">.</span><span class="pl-en">isEmail</span><span class="pl-kos">(</span><span class="pl-s">'foo@bar.com'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// I want the `isEmail` symbol, without having to `const isEmail = validators.isEmail`</span></pre></div>
<h4 dir="auto">marker.d.ts</h4>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare var marker: marker.marker;

declare module marker {
    export interface marker {
        validators: IValidators;
    }

    export interface IValidators {
        isEmail(input: string): boolean;
    }
}

export = marker;"><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">var</span> <span class="pl-s1">marker</span>: <span class="pl-s1">marker</span><span class="pl-kos">.</span><span class="pl-smi">marker</span><span class="pl-kos">;</span>

<span class="pl-k">declare</span> module <span class="pl-s1">marker</span> <span class="pl-kos">{</span>
    <span class="pl-k">export</span> <span class="pl-k">interface</span> <span class="pl-smi">marker</span> <span class="pl-kos">{</span>
        <span class="pl-c1">validators</span>: <span class="pl-smi">IValidators</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">export</span> <span class="pl-k">interface</span> <span class="pl-smi">IValidators</span> <span class="pl-kos">{</span>
        <span class="pl-c1">isEmail</span><span class="pl-kos">(</span><span class="pl-s1">input</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">boolean</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-s1">marker</span><span class="pl-kos">;</span></pre></div>
<h4 dir="auto">index.ts</h4>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import * as vs from './validators'

export const validators = vs;"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">vs</span> <span class="pl-k">from</span> <span class="pl-s">'./validators'</span>

<span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-s1">validators</span> <span class="pl-c1">=</span> <span class="pl-s1">vs</span><span class="pl-kos">;</span></pre></div>
<h4 dir="auto">validators.ts</h4>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export function isEmail(input: string): boolean { return true }"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">function</span> <span class="pl-en">isEmail</span><span class="pl-kos">(</span><span class="pl-s1">input</span>: <span class="pl-smi">string</span><span class="pl-kos">)</span>: <span class="pl-smi">boolean</span> <span class="pl-kos">{</span> <span class="pl-k">return</span> <span class="pl-c1">true</span> <span class="pl-kos">}</span></pre></div>
<hr>
<p dir="auto">How am I meant to do this, e.g.: <code class="notranslate">namespace</code>s?</p>
<p dir="auto">BTW: Asked on <a href="http://stackoverflow.com/q/37370601" rel="nofollow">StackOverlfow</a> also</p>