Skip to content

TS2300: Duplicate identifier #14687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
monolithed opened this issue Mar 16, 2017 · 4 comments
Closed

TS2300: Duplicate identifier #14687

monolithed opened this issue Mar 16, 2017 · 4 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@monolithed
Copy link

TypeScript Version: 2.2.1

{
	"compilerOptions": {
		"typeRoots": [
			"./node_modules/@types",
			"./types"
		],

		"outDir": "cache/",

		"types": [
			"debug",
			"deepmerge",
			"imap",
			"faker",
			"minimist",
			"mocha",
			"nodemailer",
			"node",
			"request",
			"webdriverio"
		],

		"lib": [
			"es2017",
			"scripthost",
			"webworker",
			"dom"
		],

		"target": "es2017",
		"module": "commonjs",
		"moduleResolution": "node",
		"noImplicitAny": false,

		"declaration": false,
		"allowJs": true,

		"emitDecoratorMetadata": true,
		"experimentalDecorators": true,
		"sourceMap": true
	},

	"exclude": [
		"./config.js",
		"./config.local.js",
		"./node_modules",
		"./utils",
		"./tasks",
		"./files",
		"./cache"
	]
}
➜ tsc
/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14171,14): error TS2300: Duplicate identifier 'EventListenerOrEventListenerObject'.
/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14897,6): error TS2300: Duplicate identifier 'AlgorithmIdentifier'.
/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14898,6): error TS2300: Duplicate identifier 'BodyInit'.
/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14920,6): error TS2300: Duplicate identifier 'IDBKeyPath'.
/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14929,6): error TS2300: Duplicate identifier 'RequestInfo'.
/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14930,6): error TS2300: Duplicate identifier 'USVString'.
/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14934,6): error TS2300: Duplicate identifier 'IDBValidKey'.
/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14935,6): error TS2300: Duplicate identifier 'BufferSource'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(72,5): error TS2403: Subsequent variable declarations must have the same type.  Variable 'source' must be of type 'Window', but here has type 'any'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(367,5): error TS2375: Duplicate number index signature.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(398,14): error TS2403: Subsequent variable declarations must have the same type.  Variable 'srcElement' must be of type 'Element', but here has type 'any'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(446,5): error TS2375: Duplicate number index signature.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(715,14): error TS2403: Subsequent variable declarations must have the same type.  Variable 'source' must be of type 'Window', but here has type 'any'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1096,14): error TS2403: Subsequent variable declarations must have the same type.  Variable 'responseXML' must be of type 'Document', but here has type 'any'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1684,14): error TS2300: Duplicate identifier 'EventListenerOrEventListenerObject'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1710,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'onmessage' must be of type '(this: Window, ev: MessageEvent) => any', but here has type '(this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1715,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'location' must be of type 'Location', but here has type 'WorkerLocation'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1716,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'onerror' must be of type 'ErrorEventHandler', but here has type '(this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1718,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'self' must be of type 'Window', but here has type 'WorkerGlobalScope'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1724,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'navigator' must be of type 'Navigator', but here has type 'WorkerNavigator'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1743,6): error TS2300: Duplicate identifier 'AlgorithmIdentifier'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1744,6): error TS2300: Duplicate identifier 'BodyInit'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1745,6): error TS2300: Duplicate identifier 'IDBKeyPath'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1746,6): error TS2300: Duplicate identifier 'RequestInfo'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1747,6): error TS2300: Duplicate identifier 'USVString'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1748,6): error TS2300: Duplicate identifier 'IDBValidKey'.
/usr/local/lib/node_modules/typescript/lib/lib.webworker.d.ts(1749,6): error TS2300: Duplicate identifier 'BufferSource'.

I see these errors with lib.webworker

@RyanCavanaugh
Copy link
Member

You can't target webworker and dom at the same time -- these are mutually exclusive, and have different types for certain global variables. You'll need two separate compilations, one for the code which runs in your webworker threads, and one for code which runs in the DOM

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Mar 16, 2017
@monolithed
Copy link
Author

@RyanCavanaugh, I got it, thanks! Could you show such errors not like a stack trace?

@RyanCavanaugh
Copy link
Member

Not sure what you mean?

@monolithed
Copy link
Author

/usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts(14171,14): error TS2300: Duplicate identifier 'EventListenerOrEventListenerObject'.

Usually such error messages are not informative. It would be nice to print something like:

You can't target webworker and dom at the same time -- these are mutually exclusive, and have different types for certain global variables. You'll need two separate compilations, one for the code which runs in your webworker threads, and one for code which runs in the DOM

😉

@mhegazy mhegazy closed this as completed Apr 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants