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

Variable "name" in VSCode editor(intelli-sense) is showing incorrect information #39534

Open
preethidaran opened this issue Jul 9, 2020 · 3 comments
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript

Comments

@preethidaran
Copy link

preethidaran commented Jul 9, 2020

TS Template added by @mjbvz

TypeScript Version: 4.0.0-dev.20200708

Search Terms

  • javascript
  • lib.dom
  • globals

  • VSCode Version: 1.46.1
  • OS Version: Windows 10

Steps to Reproduce:

  1. Add the following javascript code

var name = "Hi";
console.log(name);
name = "Hello";
console.log(name);

  1. Hover over(Mouseover) the variable "name" (in any of the console log statements given above).......picture attached.

  2. Expected: During mouse/hover over, variable "name" on the console statement should display "name" as a variable.

    Actual: During mouse/hover over, variable "name" on the console statement is showing it as constant. (actually, it's not a constant). Because I'm able to modify the value of the variable "name" from "Hi" to "Hello". This explains "name" is implemented as a variable.

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

VSCode bug

@mjbvz mjbvz transferred this issue from microsoft/vscode Jul 9, 2020
@mjbvz
Copy link
Contributor

mjbvz commented Jul 9, 2020

Duplicate of #31783. See that issue for details

@RyanCavanaugh This has been reported a few times now so I wonder if there's anything we can do. I suspect beginning JS users are most likely to hit this since:

  • They are not using modules
  • They are writing code in the global scope.
  • They would not know about the lib.dom typings or how to fix the issue

@mjbvz mjbvz removed their assignment Jul 9, 2020
@RyanCavanaugh RyanCavanaugh added Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript labels Jul 10, 2020
@RyanCavanaugh
Copy link
Member

@mjbvz open to suggestions here. Not sure what might do since there's really no way to tell if this file is intended for a DOM context or not

@mjbvz
Copy link
Contributor

mjbvz commented Jul 15, 2020

One old idea I had was an option that forces TS to treat each file as an implicit module (even if it does not use import or export): #14279. I believe that would also address this issue.

We could also be more pragmatic and just remove the name global from the dom typings. That seems to be the variable that people hit this problem with most often (and I suspect there is not much real world code that uses the name global)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants