TS2300: Duplicate identifier TypeScript Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

TypeScript: error TS2300: Duplicate identifier 'Foo'.

The same name is declared twice in the same scope (or in merged global declarations).

Exact message you may see error TS2300: Duplicate identifier 'Foo'.TS2300: Duplicate identifierDuplicate identifier 'Promise'. ts(2300)error TS2300: Duplicate identifier 'require'
Seen on: TypeScript

Meaning

Rename or remove one declaration. In projects it often means two copies of type definitions (@types/node twice, lib.dom plus another DOM typing), or files being both included and re-declared. Check include/exclude and duplicated @types packages.

Common causes

  • Two declarations with the same name (not merge-compatible)
  • Duplicate @types versions in node_modules
  • Same file included twice
  • Global script files redeclaring types
  • Copy-paste

⚡ Quick fix

  1. Rename/remove the duplicate
  2. npm ls @types/node and dedupe
  3. Convert global scripts to modules with export {}

Detailed fix by platform

Linux

  1. npm ls @types/node @types/react && npm dedupe

How to diagnose

  1. Names — Duplicate where?
  2. Types — Duplicate packages?
  3. Files — Modules?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Cannot find module './App.vue' or its corresponding type declarations — TypeScript: error TS2307: Cannot find module './App.vue' or its corresponding type declarations. (Vue)Cannot find module '.…TS1005: ';' expected / ',' expected (syntax error) — TypeScript: error TS1005: ';' expected. (TypeScript)TS1005: ';' expected …TS1128: Declaration or statement expected — TypeScript: error TS1128: Declaration or statement expected. (TypeScript)TS1128: Declaration o…TS2304 — TS2304: Cannot find name 'x'. (Node.js)TS2304TS2393: Duplicate function implementation — TypeScript: error TS2393: Duplicate function implementation. (TypeScript)TS2393: Duplicate fun…TS2403: Subsequent variable declarations must have the same type — TypeScript: error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'string', but here has type 'number'. (TypeScript)TS2403: Subsequent va…TS2451: Cannot redeclare block-scoped variable — TypeScript: error TS2451: Cannot redeclare block-scoped variable 'name'. (TypeScript)TS2451: Cannot redecl…TS4023/TS2742: exported variable has or is using name from external module but cannot be named — TypeScript: error TS4023: Exported variable 'x' has or is using name 'Foo' from external module "..." but cannot be named. / TS2742: The inferred type cannot be named without a reference (TypeScript)TS4023/TS2742: export…TS2300: D…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.