<p dir="auto">Consider a simplified version of <a href="https://github.com/borisyankov/DefinitelyTyped/blob/8f081073e6cb416f901b272810d8b04d6e01c9e0/nouislider/nouislider.d.ts">the .d.ts file for 'nouislider'</a>:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare namespace myFramework {
    interface Static {
        create(blahArray: any[]): Instance;
    } 

    interface Instance {
        /**
         * Returns 0, 1, or 2, depending on if the stars align.
         */
        doFoo(): number
    }
}

declare var myFramework: myFramework.Static;"><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">namespace</span> <span class="pl-s1">myFramework</span> <span class="pl-kos">{</span>
    <span class="pl-k">interface</span> <span class="pl-smi">Static</span> <span class="pl-kos">{</span>
        <span class="pl-c1">create</span><span class="pl-kos">(</span><span class="pl-s1">blahArray</span>: <span class="pl-smi">any</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span>: <span class="pl-smi">Instance</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span> 

    <span class="pl-k">interface</span> <span class="pl-smi">Instance</span> <span class="pl-kos">{</span>
        <span class="pl-c">/**</span>
<span class="pl-c">         * Returns 0, 1, or 2, depending on if the stars align.</span>
<span class="pl-c">         */</span>
        <span class="pl-c1">doFoo</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">number</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">declare</span> <span class="pl-k">var</span> <span class="pl-s1">myFramework</span>: <span class="pl-s1">myFramework</span><span class="pl-kos">.</span><span class="pl-smi">Static</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><code class="notranslate">doFoo</code> currently returns one of 3 different values. <code class="notranslate">number</code> is a little more broad than one would prefer, so one might be tempted to say "I know, I'll use a const enum!":</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="declare namespace myFramework {
    interface Static {
        create(blahArray: any[]): Instance;
    } 

    interface Instance {
        /**
         * Returns 0, 1, or 2, depending on if the stars align.
         */
        doFoo(): number
    }

    const enum FooReturnValue {
        StarsTotallyAlign,
        StarsTotallyDontAlign,
        EhCloseEnough
    }
}

declare var myFramework: myFramework.Static;"><pre class="notranslate"><span class="pl-k">declare</span> <span class="pl-k">namespace</span> <span class="pl-s1">myFramework</span> <span class="pl-kos">{</span>
    <span class="pl-k">interface</span> <span class="pl-smi">Static</span> <span class="pl-kos">{</span>
        <span class="pl-c1">create</span><span class="pl-kos">(</span><span class="pl-s1">blahArray</span>: <span class="pl-smi">any</span><span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span>: <span class="pl-smi">Instance</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span> 

    <span class="pl-k">interface</span> <span class="pl-smi">Instance</span> <span class="pl-kos">{</span>
        <span class="pl-c">/**</span>
<span class="pl-c">         * Returns 0, 1, or 2, depending on if the stars align.</span>
<span class="pl-c">         */</span>
        <span class="pl-c1">doFoo</span><span class="pl-kos">(</span><span class="pl-kos">)</span>: <span class="pl-smi">number</span>
    <span class="pl-kos">}</span>

    <span class="pl-k">const</span> <span class="pl-k">enum</span> <span class="pl-smi">FooReturnValue</span> <span class="pl-kos">{</span>
        <span class="pl-c1">StarsTotallyAlign</span><span class="pl-kos">,</span>
        <span class="pl-c1">StarsTotallyDontAlign</span><span class="pl-kos">,</span>
        <span class="pl-c1">EhCloseEnough</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-k">declare</span> <span class="pl-k">var</span> <span class="pl-s1">myFramework</span>: <span class="pl-s1">myFramework</span><span class="pl-kos">.</span><span class="pl-smi">Static</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Now that person has two problems:</p>
<table role="table">
<thead>
<tr>
<th>Severity</th>
<th>Code</th>
<th>Description</th>
<th>File</th>
<th>Line</th>
</tr>
</thead>
<tbody>
<tr>
<td>Error</td>
<td>TS2300</td>
<td>Duplicate identifier 'myFramework'.</td>
<td>myFramework.ts</td>
<td>1</td>
</tr>
<tr>
<td>Error</td>
<td>TS2300</td>
<td>Duplicate identifier 'myFramework'.</td>
<td>myFramework.ts</td>
<td>20</td>
</tr>
</tbody>
</table>
<p dir="auto">Apparently, the <code class="notranslate">FooReturnValue</code> causes the namespace to be instantiated.</p>
<p dir="auto">Note:One might say that the solution is to just absorb <code class="notranslate">Static</code> into the <code class="notranslate">myFramework</code> namespace and just instantiate it there, which seems reasonable, but it is still an odd quirk that there is no way to control that a const enum can instantiate a module</p>
<p dir="auto">When using a tsconfig file with no <code class="notranslate">files</code> property all declaration files under node_modules are currently pulled in. This is especially problematic if typescript itself resides under node_modules since you wind up with duplicate identifiers from <code class="notranslate">lib.core.d.ts</code> and <code class="notranslate">lib.core.es6.d.ts</code>, etc. I realize this is partially taken care of with <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="73382462" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/3043" data-hovercard-type="issue" data-hovercard-url="/microsoft/TypeScript/issues/3043/hovercard" href="https://github.com/microsoft/TypeScript/issues/3043">#3043</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="77102652" data-permission-text="Title is private" data-url="https://github.com/microsoft/TypeScript/issues/3188" data-hovercard-type="pull_request" data-hovercard-url="/microsoft/TypeScript/pull/3188/hovercard" href="https://github.com/microsoft/TypeScript/pull/3188">#3188</a> but I'm wondering if there should be a special default case of excluding typescript declaration files. Plugins for JS toolchains like <a href="https://github.com/ivogabe/gulp-typescript/blob/master/package.json">gulp-typescript</a> and <a href="https://github.com/jbrantly/ts-loader/blob/master/package.json">ts-loader</a> pull in typescript locally so this becomes an issue there.</p>
<p dir="auto">Edit: Repro steps for TS 1.5 beta</p>
<ol dir="auto">
<li><code class="notranslate">mkdir test</code></li>
<li><code class="notranslate">cd test</code></li>
<li><code class="notranslate">npm install typescript</code> (install locally, not globally)</li>
<li><code class="notranslate">touch tsconfig.json</code></li>
<li><code class="notranslate">./node_modules/typescript/bin/tsc</code></li>
</ol>