TS2451: Cannot redeclare block-scoped variable - in CI
A let/const name was declared twice in the same scope, or a file without imports/exports collides with global declarations.
What this error means
Type-checking fails with TS2451 naming the redeclared variable, sometimes across two files treated as one global scope.
tsc
src/index.ts(1,7): error TS2451: Cannot redeclare block-scoped variable 'name'.Common causes
How to fix it
Make the file a module
- Add an import or export so the file gets its own module scope
ts
export {}Rename or remove the duplicate
- Rename one declaration, or delete the redundant one
How to prevent it
- Use modules (import/export) rather than global scripts, and avoid names that shadow DOM globals.
Related guides
TS2300: Duplicate identifier - in CIFix "error TS2300: Duplicate identifier 'x'" when tsc runs in CI - the same name declared twice, often from c…
TS1208: isolatedModules - file cannot be compiled - in CIFix "error TS1208: ... cannot be compiled under '--isolatedModules' because it is considered a global script…