<p dir="auto">I'm using typescript 1.7.5, typings 0.6.9 and angular 2.0.0-beta.0.</p>
<p dir="auto">How can I get rid of the typescript compile error messages <code class="notranslate">Duplicate identifier</code> due to typings definition files?</p>
<p dir="auto">The <code class="notranslate">Duplicate identifier</code> error occurs in the definition files of the following directories:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="node_modules/angular2/typings/es6-shim/es6-shim.d.ts
node_modules/angular2/typings/jasmine/jasmine.d.ts
node_modules/angular2/typings/zone/zone.d.ts
typings/browser/ambient/es6-promise/es6-promise.d.ts
typings/browser/ambient/es6-shim/es6-shim.d.ts
typings/browser/ambient/jasmine/jasmine.d.ts
typings/browser/ambient/karma/karma.d.ts
typings/browser/ambient/zone.js/zone.js.d.ts"><pre class="notranslate"><code class="notranslate">node_modules/angular2/typings/es6-shim/es6-shim.d.ts
node_modules/angular2/typings/jasmine/jasmine.d.ts
node_modules/angular2/typings/zone/zone.d.ts
typings/browser/ambient/es6-promise/es6-promise.d.ts
typings/browser/ambient/es6-shim/es6-shim.d.ts
typings/browser/ambient/jasmine/jasmine.d.ts
typings/browser/ambient/karma/karma.d.ts
typings/browser/ambient/zone.js/zone.js.d.ts
</code></pre></div>
<p dir="auto">What's the compiler doing in <code class="notranslate">node_modules/angular2</code> directory since I excluded it in <code class="notranslate">tsconfig.json</code>?</p>
<p dir="auto"><a href="http://stackoverflow.com/questions/35776470/typescript-compile-error-due-to-typings" rel="nofollow">I also posted this question on StackOverflow</a></p>
<p dir="auto">tsconfig.json</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
    &quot;compilerOptions&quot;: {
        &quot;target&quot;: &quot;es5&quot;,
        &quot;module&quot;: &quot;system&quot;,
        &quot;moduleResolution&quot;: &quot;node&quot;,
        &quot;sourceMap&quot;: true,
        &quot;emitDecoratorMetadata&quot;: true,
        &quot;experimentalDecorators&quot;: true,
        &quot;removeComments&quot;: false,
        &quot;noImplicitAny&quot;: false
    },
    &quot;exclude&quot;: [
        &quot;node_modules&quot;,
        &quot;typings/main&quot;,
        &quot;typings/main.d.ts&quot;
    ]
}"><pre class="notranslate"><code class="notranslate">{
    "compilerOptions": {
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}
</code></pre></div>
<p dir="auto">They are gone if I change the <code class="notranslate">exclude</code> part of <code class="notranslate">tsconfig.json</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;exclude&quot;: [
    &quot;node_modules&quot;,
    &quot;typings&quot;
]"><pre class="notranslate"><code class="notranslate">"exclude": [
    "node_modules",
    "typings"
]
</code></pre></div>
<p dir="auto">But then after adding the following I get again the same <code class="notranslate">Duplicate identifier</code> compile errors:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/// &lt;reference path=&quot;../../typings/browser.d.ts&quot; /&gt;"><pre class="notranslate"><code class="notranslate">/// &lt;reference path="../../typings/browser.d.ts" /&gt;
</code></pre></div>
<p dir="auto">typings.json</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;name&quot;: &quot;example-mean-app-client&quot;,
  &quot;dependencies&quot;: {},
  &quot;devDependencies&quot;: {},
  &quot;ambientDependencies&quot;: {
    &quot;bootstrap&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/bootstrap/bootstrap.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c&quot;,
    &quot;es6-promise&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/es6-promise/es6-promise.d.ts#830e8ebd9ef137d039d5c7ede24a421f08595f83&quot;,
    &quot;es6-shim&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c&quot;,
    &quot;jasmine&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4&quot;,
    &quot;karma&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/karma/karma.d.ts#02dd2f323e1bcb8a823269f89e0909ec9e5e38b5&quot;,
    &quot;karma-jasmine&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/karma-jasmine/karma-jasmine.d.ts#661e01689612eeb784e931e4f5274d4ea5d588b7&quot;,
    &quot;systemjs&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/systemjs/systemjs.d.ts#83af898254689400de8fb6495c34119ae57ec3fe&quot;,
    &quot;zone.js&quot;: &quot;github:DefinitelyTyped/DefinitelyTyped/zone.js/zone.js.d.ts#9027703c0bd831319dcdf7f3169f7a468537f448&quot;
  }
}"><pre class="notranslate"><code class="notranslate">{
  "name": "example-mean-app-client",
  "dependencies": {},
  "devDependencies": {},
  "ambientDependencies": {
    "bootstrap": "github:DefinitelyTyped/DefinitelyTyped/bootstrap/bootstrap.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
    "es6-promise": "github:DefinitelyTyped/DefinitelyTyped/es6-promise/es6-promise.d.ts#830e8ebd9ef137d039d5c7ede24a421f08595f83",
    "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
    "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4",
    "karma": "github:DefinitelyTyped/DefinitelyTyped/karma/karma.d.ts#02dd2f323e1bcb8a823269f89e0909ec9e5e38b5",
    "karma-jasmine": "github:DefinitelyTyped/DefinitelyTyped/karma-jasmine/karma-jasmine.d.ts#661e01689612eeb784e931e4f5274d4ea5d588b7",
    "systemjs": "github:DefinitelyTyped/DefinitelyTyped/systemjs/systemjs.d.ts#83af898254689400de8fb6495c34119ae57ec3fe",
    "zone.js": "github:DefinitelyTyped/DefinitelyTyped/zone.js/zone.js.d.ts#9027703c0bd831319dcdf7f3169f7a468537f448"
  }
}
</code></pre></div>
<p dir="auto">After updated TS to 1.5-beta, my code failed to compile. My code uses a few ES6 APIs such as <code class="notranslate">Set</code>, but the <code class="notranslate">--target</code> is still ES5. It seems TS 1.5-beta removed those ES6 APIs from <code class="notranslate">lib.d.ts</code> when targeting ES5. I think this is a bad change.</p>
<p dir="auto">ES6+'s new language features and new APIs are very different stories. New APIs are shipped earlier in browsers, and can be polyfilled; language features are shipped later, and can't be polyfilled.</p>
<p dir="auto">My code is targeting modern browsers, so relying on <code class="notranslate">Set</code> etc. is not a problem. But for obvious reason I can't specify <code class="notranslate">--target ES6</code> for <code class="notranslate">tsc</code> because ES6 new language features are not enabled by default in all browsers.</p>
<p dir="auto">We may have two options to solve this problem:</p>
<ul dir="auto">
<li>Restore all ES6+ APIs in <code class="notranslate">lib.d.ts</code>. This may be a short-term solution.</li>
<li>Add a <code class="notranslate">--source</code> option to tsc to specify a "source code API level", values are same as <code class="notranslate">--target</code>. This is similar to <code class="notranslate">javac -source</code> option. So I can invoke <code class="notranslate">tsc --source ES6 --target ES5</code>. This may be a long-term solution.</li>
</ul>