Issue 1:
I'm experiencing a lot of Duplicate identifiers errors. I see around 80 similar issues, but I don't see a clear and workable solution anywhere. Not on stackoverflow neither.

I'm using current Typescript, e.g. tsc v1.7.5. The exclude option in tsconfig does not seem to be respected, as I get around a 100 Duplicate identifier issues when compiling. All in the typings folders. See below. Before I had similar errors in node_modules files, but they seem to have disappeared after adding node_modules in my tsconfig's exclude. But similarly adding typings (and client/typings) does NOT fix this issue.

I'm currently using - only - this in a few of my own .ts. But most don't have any at all. At least NOwhere am I referencing int

/// <reference path="typings/tsd.d.ts" />

Can you give advice how to solve this? Or is this a temporary bug to be fixed?

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 😭.

tsd.json

{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"node_modules",
"bower_components",
"typings",
"client/typings"
]
}

Sample from error output

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'.

Issue 2:
I'm having an issue with duplicate identifier errors. It appears to stem from having the same definitions listed in multiple places.

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:

|-- server.ts
|-- tsd.json
|-- typings
|-- lib
|-- mylib.ts
|-- tsd.json
|-- typings

Here is the code for and for mylib.ts:

/// <reference path="./typings/tsd.d.ts"/>
import Promise = require('bluebird')
class MyLib {
}
export = MyLib

and server.ts:

/// <reference path="./typings/tsd.d.ts"/>
import Promise = require('bluebird')
import MyLib = require('./lib/mylib')
class Server {
}
export = Server

As you can see, both server.ts and mylib.ts use the bluebird library. Since server.ts uses mylib.ts, it ends up importing bluebird twice, which results in errors. So when I run

tsc server.ts --module commonjs

I get

lib/typings/bluebird/bluebird.d.ts(705,9): error TS2300: Duplicate identifier 'concurrency'.

lib/typings/bluebird/bluebird.d.ts(708,9): error TS2300: Duplicate identifier 'spread'.

lib/typings/bluebird/bluebird.d.ts(711,9): error TS2300: Duplicate identifier 'suffix'.

typings/bluebird/bluebird.d.ts(705,9): error TS2300: Duplicate identifier 'concurrency'.

typings/bluebird/bluebird.d.ts(708,9): error TS2300: Duplicate identifier 'spread'.

typings/bluebird/bluebird.d.ts(711,9): error TS2300: Duplicate identifier 'suffix'.

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 tsd.json file and corresponding typings folder at the root of my project and having all the typescript definitions live there. Is that the generally accepted way to structure things?