Why do i get 'cannot redeclare block-scoped variable x' in typescript?

This error suggests you're trying to declare a variable in the same scope where it's already been declared.

Example:


let user = 'Alice';
let user = 'Bob';

Solution:


let user = 'Alice';
user = 'Bob';
Avoid re-declaring variables in the same scope; you can reassign them instead.

Beginner's Guide to TypeScript