TS2300: Duplicate identifier 'export=' error when use Electron in TypeScript


#1

I wrote two TypeScript files and use electron render and electron main type definitions,
the codes are below.

rend.ts

/// <reference path="./typings/github-electron/github-electron-renderer.d.ts" />

import ipc = require('ipc');

export class Rend {
	sendDataToMain(command, data) {
		ipc.send('main-channel', 'signal', command, data);
	}
}

main.ts

/// <reference path="./typings/github-electron/github-electron-main.d.ts" />

//import ipc = require('ipc');

export class Main {
	foo(event, status) {
	}

}

tsconfig.json

{
	"compilerOptions": {
		"target": "ES5",
		"module": "commonjs",
		"sourceMap": true,
		"watch": true,
		"outDir": "./js/"
		},
	
	"exclude": [
		"node_modules",
		"typings"
	]
}

The problem is when build TypeScript files use command tsc -w,
the console shows the error below, while in fact the js files are generated successfully.

tstest/script/rend.ts
	Error:(7, 7) TS2339: Property 'send' does not exist on type 'EventEmitter'.
tstest/script/typings/github-electron/github-electron-main.d.ts
	Error:(229, 2) TS2300: Duplicate identifier 'export='.
tstest/script/typings/github-electron/github-electron-renderer.d.ts
	Error:(99, 2) TS2300: Duplicate identifier 'export='.

If i delete file main.ts or just delete the reference path line from main.ts,
the error above will disappear.

I looks like if use github-electron-renderer.d.ts and github-electron-main.d.ts in one project,
this problem will occurs, even though they are not reference in one TypeScript file.

[Environment]
tsc version 1.6.2


#2

I experience this issue too. I suppose the workaround is to have two tsconfigs and folder structures to separate code belonging to main vs renderer processes…
Not a bad idea anyway…