Skip to content

"Cannot redeclare block-scoped variable length" #43398

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

Closed
JacksonKearl opened this issue Mar 26, 2021 · 3 comments
Closed

"Cannot redeclare block-scoped variable length" #43398

JacksonKearl opened this issue Mar 26, 2021 · 3 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@JacksonKearl
Copy link

When I try to work on a JS file that has a "const length = 100" line at the top with "js/ts.implicitProjectConfig.checkJs": true, I get an ugly "Cannot redeclare block-scoped variable length" error because it conflicts with some lib.dom.ts file... but that's in fact not a concern at all:
image

I think something like this would probably pose a significant barrier to folks trying to get started with checkJS.

@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 26, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Mar 26, 2021

This is a duplicate of #31783

Moving upstream for more feedback. I don't think the code causes issues when run in a browser

@mjbvz mjbvz removed their assignment Mar 26, 2021
@JacksonKearl
Copy link
Author

Correct, I tried in node and browser contexts with no issues.

@RyanCavanaugh RyanCavanaugh added Working as Intended The behavior described is the intended behavior; this is not a bug Design Limitation Constraints of the existing architecture prevent this from being fixed and removed Working as Intended The behavior described is the intended behavior; this is not a bug labels Mar 26, 2021
@RyanCavanaugh
Copy link
Member

The problem here is that if you downlevel this code to var, it starts misbehaving again, and we don't know whether or not you're doing that. Beside that, we could add some logic here to separate the "global scope that's actually global" and the "global scope that is shadowable with a block-scope let/const" but to be honest this really doesn't seem to come up much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

3 participants