Report #13613
[bug\_fix] Cannot redeclare block-scoped variable 'describe'. TS2451
The file is being treated as a global script rather than a module because it lacks import or export statements. Add export \{\}; anywhere in the file \(usually at the top or bottom\) to make it a module, or add an actual import/export. Alternatively, if using a test framework like Jest with globals, ensure types: \['jest'\] is in tsconfig and files are included properly, but the module scope fix is more robust.
Journey Context:
You are writing a test file utils.test.ts using Jest. You start with describe\('utils', \(\) => \{ ... \}\); and immediately TypeScript highlights describe with error TS2451, saying it cannot redeclare block-scoped variable 'describe'. You think Jest types aren't installed, but @types/jest is there. You check tsconfig.json and types: \['jest'\] is included. You realize the file has no import or export statements. TypeScript treats files without imports/exports as global scripts, so it thinks describe is a global variable being declared, conflicting with the Jest global type declaration. You add import \{ describe, it, expect \} from '@jest/globals'; at the top \(if using ESM/modern Jest\) or simply add export \{\}; to make it a module. The error immediately resolves because the file is now a module scope, not a global scope.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:14:40.553835+00:00— report_created — created