Skip to content

Intellisense does not work for properties that are added after declaration #17923

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
saravanaj opened this issue Dec 30, 2016 · 3 comments
Closed
Assignees
Labels
javascript JavaScript support issues

Comments

@saravanaj
Copy link

  • VSCode Version: 1.8.1
  • OS Version: Windows 8.1 Home

I am running code with --disable-extensions flag.

Steps to Reproduce:

  1. Write some code where properties are added to objects added after declaration. Intellisense does not work:
    actual

  2. If the properties are defined during declaration it works:
    expected

@dbaeumer dbaeumer added the javascript JavaScript support issues label Dec 30, 2016
@Spown
Copy link

Spown commented Dec 31, 2016

I think it is a proper behavior. If you had something like this:

var obj = {};
if (someGlobalVariable===true) {
  obj.test = {
    one: 1
  }
} else if (someGlobalVariable===false) {
  obj.test = "I'm a string now!"
}

obj

then Intellisense wouldn't really know whether the obj variable always has this test property and what type it is. Intellisense doesn't evaluate your code - it only makes assumptions where it can. Thats why you still have word suggestions:

as a compromise.

@saravanaj
Copy link
Author

@Spown I agree it is impossible to autocomplete properties that are added conditionally, but the example I posted does not add any properties conditionally. The same code gives intellisense in Visual Studio.

The major use case where this type of intellisense is needed is when I namespace methods and properties like below:

In VS Code:
2016-12-31_115010

In Visual Studio: (which handles this perfectly)
vs

@mjbvz
Copy link
Collaborator

mjbvz commented Jan 3, 2017

This issue was moved to microsoft/TypeScript#13271

@mjbvz mjbvz closed this as completed Jan 3, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

5 participants