Skip to content
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

Global variable name is marked deprecated #114725

Closed
humphd opened this issue Jan 21, 2021 · 5 comments
Closed

Global variable name is marked deprecated #114725

humphd opened this issue Jan 21, 2021 · 5 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) javascript JavaScript support issues

Comments

@humphd
Copy link

humphd commented Jan 21, 2021

  • Version: 1.52.1
  • Commit: ea3859d
  • Date: 2020-12-16T16:30:02.420Z (1 mo ago)
  • Electron: 9.3.5
  • Chrome: 83.0.4103.122
  • Node.js: 12.14.1
  • V8: 8.3.110.13-electron.0
  • OS: Darwin x64 18.7.0

Steps to Reproduce:

  1. Create a new JavaScript file
  2. Add a variable name, for example: let name = 'foo';
  3. Try using the name variable, for example: console.log(name);

Screen Shot 2021-01-21 at 4 14 11 PM

Does this issue occur when all extensions are disabled?: No

I suspect this is an eslint bug, or bug in the vscode-eslint extension, not distinguishing between a user-defined name variable and the global. But I'm not sure where to file it other than here.

@IllusionMH
Copy link
Contributor

This is "intended" TS behavior for global name until there is beter solution.
See microsoft/TypeScript-DOM-lib-generator#883 and linked issue

@mjbvz
Copy link
Contributor

mjbvz commented Jan 21, 2021

Yep, duplicate of microsoft/TypeScript#18433

@mjbvz mjbvz closed this as completed Jan 21, 2021
@mjbvz mjbvz added *duplicate Issue identified as a duplicate of another issue(s) javascript JavaScript support issues labels Jan 21, 2021
@thw0rted
Copy link

Maybe I misunderstand the scope here? The issue says they're declaring a locally-scoped name variable, but the warning is being shown because of the globally scoped window.name. Right? Shouldn't let name shadow out the name that comes from window or globalThis or whatever?

@IllusionMH
Copy link
Contributor

If you are talking about JS runtime - yes.
In JS/TS there will be no problems with name in case when you have module scope (file has import or export). Or if it's not script that will be executed in browser - make sure that dom is excluded form lib compiler options.

For global scope it becomes tricky especially for name that intentionally declared to prevent usage.
Conflict with let looks like design limitation and/or intended behavior (because in TS you'll get "Cannot redeclare block-scoped variable 'name'." error on let name) until there is better solution.

I don't think that this case can be fixed in VS Code so it's better to check existing issues in TS repo or rise new one there.

@jacksonfagundes2007
Copy link

Hi! I know how to solve this error ... If I don't, I don't know what to do.

In my case the problem happened because the "Discord Rich Presence" extension is down ... Try disabling it.

result:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

5 participants