Skip to content
Latchkey

TS2300: Duplicate identifier - in CI

tsc found the same identifier declared more than once in a way that conflicts.

What this error means

Type-checking fails with TS2300 naming the duplicated identifier, frequently from two copies of a @types package.

tsc
node_modules/@types/node/globals.d.ts(72,13): error TS2300: Duplicate identifier 'RequestInit'.

Common causes

How to fix it

Deduplicate type packages

  1. Find duplicate @types in the tree and dedupe to one version
shell
npm ls @types/node

Scope the included types

  1. Pin compilerOptions.types to only the packages you need
  2. Adjust lib so it does not duplicate a @types global
tsconfig.json
{
  "compilerOptions": {
    "types": ["node"]
  }
}

How to prevent it

  • Keep one version of each @types package and use a focused types allowlist to avoid global collisions.

Frequently asked questions

What causes "TS2300 duplicate identifier"?
Type-checking fails with TS2300 naming the duplicated identifier, frequently from two copies of a @types package.
How do I fix TS2300 duplicate identifier?
Deduplicate type packages

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card