Skip to content

VS Code Intellisense seems to wrongly infer revealing module pattern  #34214

Closed

Description

@lodybo
  • VSCode Version: 1.16.0
  • OS Version: Windows 10

Steps to Reproduce:

  1. Copy the code below into a file called greeter.js
  2. Run node greeter.js in a terminal
var Greeter = (function(country) {
  // Private
  this.country = country;

  function getCountry() {
    return country;
  }
  
  // Public
  var performGreeting = function (name) {
    var country = getCountry();
    
    return 'Hello ' + name + ', from ' + country;
  }
  
  return {
    greet: performGreeting
  }
});

var greeter = new Greeter("The Netherlands");
console.log(greeter.greet("Lody"));
console.log(greeter.country);

Using the revelealing module pattern in VS Code seems to trip up Intellisense into suggesting the wrong members. The code above was tested in multiple browsers and consoles and run with Node v6.3.0 which behaved as expected. They ran the greet() function and returned undefined for greeter.country:

λ node greeter.js
Hello Lody, from The Netherlands
undefined

But VS Code's Intellisense reports that greeter only contains country:
image

It also reports the expected interface of greeter for the class itself (Greeter):
image

What is expected is VS Code correctly inferring greeter.greet to be a function of Greeter, with a parameter name.

This was reproduced in a clean folder of VS Code, with no extensions (launched with code --disable-extensions), and no jsconfig.json.

Activity

  1. mjbvz commented on Sep 15, 2017

    @mjbvz
    Contributor

    This issue was moved to microsoft/TypeScript#18496

  2. added
    upstreamIssue identified as 'upstream' component related (exists outside of VS Code)
    on Sep 15, 2017
  3. locked and limited conversation to collaborators on Nov 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

javascriptJavaScript support issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions