Cannot redeclare block-scoped variable 'name' In TypeScript

Viewed 22267

Hi I am learning typescript.

I have in my code.

var name:string="Hello world";
console.log(name);

while compile time I am getting this error.

error TS2451: Cannot redeclare block-scoped variable 'name'.
index.ts(4,5): error TS2451: Cannot redeclare block-scoped variable 'name'.

Can someone describe me why I am getting this error?

3 Answers

You can add export{} at the beginning of your file.

Related