<p dir="auto">I'm experiencing a lot of <code class="notranslate">Duplicate identifiers</code> errors. I see around 80 similar issues, but I don't see a clear and workable solution anywhere. Not on <a href="http://stackoverflow.com/questions/31322525/typescript-confusing-duplicate-identifier-error-message" rel="nofollow">stackoverflow</a> neither.</p>
<p dir="auto">I'm using current Typescript, e.g. tsc v1.7.5. The <code class="notranslate">exclude</code> option in <code class="notranslate">tsconfig</code> does not seem to be respected, as I get around a 100 <code class="notranslate">Duplicate identifier</code> issues when compiling. All in the <code class="notranslate">typings</code> folders. See below. Before I had similar errors in <code class="notranslate">node_modules</code> files, but they seem to have disappeared after adding <code class="notranslate">node_modules</code> in my tsconfig's exclude. But similarly adding <code class="notranslate">typings</code> (and <code class="notranslate">client/typings</code>) does NOT fix this issue.</p>
<p dir="auto">I'm currently using - only - this in a few of my own <code class="notranslate">.ts</code>. But most don't have any at all. At least NOwhere am I referencing int</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" /// &lt;reference path=&quot;typings/tsd.d.ts&quot; /&gt;"><pre class="notranslate"><code class="notranslate"> /// &lt;reference path="typings/tsd.d.ts" /&gt;
</code></pre></div>
<p dir="auto">Can you give advice how to solve this? Or is this a temporary bug to be fixed?</p>
<p dir="auto">I already switched to Visual Studio Code and manual compiling instead of compile on save in Visual Studio with Node Tools for VS, because NTVS kept stalling the UI for dozens of seconds, killing any programmer flow 😢 . I find this typescript potentially very cool and powerful, but practically currently a bit unworkable 😭.</p>
<p dir="auto"><strong>tsd.json</strong></p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    &quot;compilerOptions&quot;: {
        &quot;module&quot;: &quot;commonjs&quot;,
        &quot;noImplicitAny&quot;: false,
        &quot;removeComments&quot;: true,
        &quot;preserveConstEnums&quot;: true,
        &quot;sourceMap&quot;: true,
        &quot;target&quot;: &quot;es5&quot;
    },
    &quot;exclude&quot;: [
        &quot;node_modules&quot;,
        &quot;bower_components&quot;,
        &quot;typings&quot;,
        &quot;client/typings&quot;
    ]
}"><pre class="notranslate">{
    <span class="pl-ent">"compilerOptions"</span>: {
        <span class="pl-ent">"module"</span>: <span class="pl-s"><span class="pl-pds">"</span>commonjs<span class="pl-pds">"</span></span>,
        <span class="pl-ent">"noImplicitAny"</span>: <span class="pl-c1">false</span>,
        <span class="pl-ent">"removeComments"</span>: <span class="pl-c1">true</span>,
        <span class="pl-ent">"preserveConstEnums"</span>: <span class="pl-c1">true</span>,
        <span class="pl-ent">"sourceMap"</span>: <span class="pl-c1">true</span>,
        <span class="pl-ent">"target"</span>: <span class="pl-s"><span class="pl-pds">"</span>es5<span class="pl-pds">"</span></span>
    },
    <span class="pl-ent">"exclude"</span>: [
        <span class="pl-s"><span class="pl-pds">"</span>node_modules<span class="pl-pds">"</span></span>,
        <span class="pl-s"><span class="pl-pds">"</span>bower_components<span class="pl-pds">"</span></span>,
        <span class="pl-s"><span class="pl-pds">"</span>typings<span class="pl-pds">"</span></span>,
        <span class="pl-s"><span class="pl-pds">"</span>client/typings<span class="pl-pds">"</span></span>
    ]
}</pre></div>
<p dir="auto"><strong>Sample from error output</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="client/typings/underscore/underscore.d.ts(53,3): error TS2374: Duplicate string index signature.
client/typings/underscore/underscore.d.ts(1693,2): error TS2300: Duplicate identifier 'templateSettings'.
client/typings/underscore/underscore.d.ts(3628,2): error TS2300: Duplicate identifier 'export='.
typings/mocha/mocha.d.ts(8,5): error TS2300: Duplicate identifier 'slow'.
typings/mocha/mocha.d.ts(11,5): error TS2300: Duplicate identifier 'timeout'.
typings/mocha/mocha.d.ts(14,5): error TS2300: Duplicate identifier 'ui'.
typings/mocha/mocha.d.ts(17,5): error TS2300: Duplicate identifier 'globals'.
typings/mocha/mocha.d.ts(20,5): error TS2300: Duplicate identifier 'reporter'."><pre lang="Errors" class="notranslate"><code class="notranslate">client/typings/underscore/underscore.d.ts(53,3): error TS2374: Duplicate string index signature.
client/typings/underscore/underscore.d.ts(1693,2): error TS2300: Duplicate identifier 'templateSettings'.
client/typings/underscore/underscore.d.ts(3628,2): error TS2300: Duplicate identifier 'export='.
typings/mocha/mocha.d.ts(8,5): error TS2300: Duplicate identifier 'slow'.
typings/mocha/mocha.d.ts(11,5): error TS2300: Duplicate identifier 'timeout'.
typings/mocha/mocha.d.ts(14,5): error TS2300: Duplicate identifier 'ui'.
typings/mocha/mocha.d.ts(17,5): error TS2300: Duplicate identifier 'globals'.
typings/mocha/mocha.d.ts(20,5): error TS2300: Duplicate identifier 'reporter'.
</code></pre></div>
<p dir="auto">I'm having an issue with duplicate identifier errors. It appears to stem from having the same definitions listed in multiple places.</p>
<p dir="auto">Let's say that I have a simple node server that utilizes the bluebird promise library. I have bluebird used in the main server code and in a library I wrote used by the server code. The structure looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="|-- server.ts
|-- tsd.json
|-- typings
|-- lib
    |-- mylib.ts
    |-- tsd.json
    |-- typings"><pre class="notranslate"><code class="notranslate">|-- server.ts
|-- tsd.json
|-- typings
|-- lib
    |-- mylib.ts
    |-- tsd.json
    |-- typings
</code></pre></div>
<p dir="auto">Here is the code for and for <code class="notranslate">mylib.ts</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/// &lt;reference path=&quot;./typings/tsd.d.ts&quot;/&gt;
import Promise = require('bluebird')
class MyLib {
}
export = MyLib"><pre class="notranslate"><code class="notranslate">/// &lt;reference path="./typings/tsd.d.ts"/&gt;
import Promise = require('bluebird')
class MyLib {
}
export = MyLib
</code></pre></div>
<p dir="auto">and  <code class="notranslate">server.ts</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/// &lt;reference path=&quot;./typings/tsd.d.ts&quot;/&gt;
import Promise = require('bluebird')
import MyLib = require('./lib/mylib')
class Server {
}
export = Server"><pre class="notranslate"><code class="notranslate">/// &lt;reference path="./typings/tsd.d.ts"/&gt;
import Promise = require('bluebird')
import MyLib = require('./lib/mylib')
class Server {
}
export = Server
</code></pre></div>
<p dir="auto">As you can see, both <code class="notranslate">server.ts</code> and <code class="notranslate">mylib.ts</code> use the bluebird library. Since <code class="notranslate">server.ts</code> uses <code class="notranslate">mylib.ts</code>, it ends up importing bluebird twice, which results in errors. So when I run</p>
<p dir="auto"><code class="notranslate">tsc server.ts --module commonjs</code></p>
<p dir="auto">I get</p>
<blockquote>
<p dir="auto">lib/typings/bluebird/bluebird.d.ts(705,9): error TS2300: Duplicate identifier 'concurrency'.<br>
lib/typings/bluebird/bluebird.d.ts(708,9): error TS2300: Duplicate identifier 'spread'.<br>
lib/typings/bluebird/bluebird.d.ts(711,9): error TS2300: Duplicate identifier 'suffix'.<br>
typings/bluebird/bluebird.d.ts(705,9): error TS2300: Duplicate identifier 'concurrency'.<br>
typings/bluebird/bluebird.d.ts(708,9): error TS2300: Duplicate identifier 'spread'.<br>
typings/bluebird/bluebird.d.ts(711,9): error TS2300: Duplicate identifier 'suffix'.</p>
</blockquote>
<p dir="auto">Tools like npm seem to be able to handle this situation. The only way I can get typescript to handle it is by having a single <code class="notranslate">tsd.json</code> file and corresponding <code class="notranslate">typings</code> folder at the root of my project and having all the typescript definitions live there. Is that the generally accepted way to structure things?</p>