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
- Find duplicate @types in the tree and dedupe to one version
shell
npm ls @types/nodeScope the included types
- Pin compilerOptions.types to only the packages you need
- 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
TS2451: Cannot redeclare block-scoped variable - in CIFix "error TS2451: Cannot redeclare block-scoped variable 'x'" when tsc runs in CI - a duplicate declaration…
TS18049: Value is possibly null or undefined - in CIFix "error TS18049: 'x' is possibly 'null' or 'undefined'" when tsc runs in CI - narrow a T | null | undefine…
TS2304: Cannot find name - in CIFix "error TS2304: Cannot find name 'x'" when tsc runs in CI - a missing import, a missing lib/types entry, o…