-
Notifications
You must be signed in to change notification settings - Fork 28k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot redeclare block-scoped variable 'name' #22436
Comments
In fact the same error can be produced with a file containing only the following line. const name = "test"; |
Thanks @rajinder-yadav I believe this behavior is by design. By default, TypeScript uses the DOM typings for the global execution environment and there is a There are two easy ways to avoid this problem:
Let me know if you run into any trouble with this |
Wow, I'm so surprised to see that typescript behaves this way. Shouldn't it suppose to act similar to nodejs where each file is a module and all variables declared in a file are locally scoped unless explicitly exported? |
@dziamid TS supports both use cases. If you use |
What about |
I added |
Below code is generating a false error:
Steps to Reproduce:
Error
The text was updated successfully, but these errors were encountered: