TS2451

error TS2451: Cannot redeclare block-scoped variable ‘window‘.

Broken Code ❌

1
const window = 'blue';

Fixed Code ✔️

Depending on the configuration of “lib” in your “tsconfig.json” file, there might be global variables that are present (like window when using the “dom” library provided by TypeScript). In this case you cannot redeclare the global variable and have to choose another name:

1
const myWindow = 'blue';