Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 18, 2022 01:09 am GMT

TypeScript and the Error: Cannot Redeclare Block Scoped Variable

Hi, Devs!

Who are getting start in Typescript could face this error: "Cannot Redeclare Block Scoped Variable Name" and it means a concept into that language.

Let's see an example:

Cannot Redeclare Block Scoped Variable Name

The error is coming because we have a TypeScript feature.

1 - The file needs to be declared as a module (exports) with its own scope.
2 - The script into file will be comprehended in a global scope.

The first example is the 2 option. So, how can we solve that? Let's see another example with the export:

export and create a scope module

Therefore, when we use the export it's created a module with its own scope and not shared in global scope.

Contacts
Email: [email protected]
Instagram: https://www.instagram.com/luizcalaca
Linkedin: https://www.linkedin.com/in/luizcalaca/
Twitter: https://twitter.com/luizcalaca


Original Link: https://dev.to/luizcalaca/typescript-and-the-error-cannot-redeclare-block-scoped-variable-289j

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To