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

Zero Intellisense for super-simple, valid, modular Node.js program #5714

Closed
mattflix opened this issue Apr 24, 2016 · 5 comments
Closed

Zero Intellisense for super-simple, valid, modular Node.js program #5714

mattflix opened this issue Apr 24, 2016 · 5 comments
Assignees

Comments

@mattflix
Copy link

mattflix commented Apr 24, 2016

  • VSCode Version: 1.0.0
  • OS Version: Mac OS 10.11.3

Steps to Reproduce:

  1. Create the example project outlined below. (This is a valid program than runs under Node.)
  2. Intellisense for imports within ./index.js does not work.

Example:

// ./jsconfig.json

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs"
    }
}
// ./index.js

var hello = require('foo');

console.log(hello('world'));
// ./node_modules/foo/index.js

module.exports = function(name) {
    return 'hello ' + name;
}

With VS Code opened to the folder designated by the dot (.) in the paths above, there is no meaningful Intellisense provided for symbol "hello" in ./index.js. Why not?

I did notice that, if an appropriate ./node_modules/foo/index.d.ts file is added, then Intellisense appears. But, I can't and/or don't want to use a Typescript definition for every module in my program.

In any case, TypeScript embellishment is beside the point... I thought VS Code was supposed to provide some minimum useful Intellisense even for plain Javascript, no? The advertised "rich editing support" features for Javascript described at https://code.visualstudio.com/Docs/languages/javascript certainly implied as much to me.

I mean, the static analysis engine should at least be able to infer that the default export of module "foo" is a function, with a parameter called "name", returning "any", right?

Or, do I not understand what the following feature descriptions (quoted from the aforementioned web page) are trying to say?

IntelliSense
The JavaScript Support uses different strategies to provide IntelliSense.

IntelliSense based on type inference
JavaScript uses the same inference as TypeScript to determine the type of a value.

The following patterns are also recognized:

"ES3-style" classes, specified using a constructor function and assignments to the prototype property.
CommonJS-style module patterns, specified as property assignments on the exports object, or assignments to the module.exports property.

The "IntelliSense based on type inference" and "CommonJS-style module patterns" is what initially caught my eye when looking into using VS Code for my Javascript work.

But, when I tried the example code shown above, in an attempt to test out both of these features, I could not get them to work even in the simplest of toy projects.

Am I doing something wrong?

@mattflix
Copy link
Author

mattflix commented Apr 25, 2016

Here's a turn-key example of the scenario described above:

NodeJsIntellisenseExample.ZIP

Just expand to a local folder and open VS Code there. Open ./index.js in the editor and attempt to invoke get Intellisense for the call to hello().

The fact that no Intelliesense appears (other than the symbol "hello" has type "any") seems to contradict the claim that:

The following patterns are also recognized:

CommonJS-style module patterns, specified as property assignments on the exports object, or assignments to the module.exports property.

Source: https://code.visualstudio.com/Docs/languages/javascript

@sarbbottam
Copy link

Similar issues:
#1648
#957

@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Apr 25, 2016
@bpasero
Copy link
Member

bpasero commented Apr 25, 2016

@dbaeumer @egamma @jrieken fyi

@egamma egamma assigned egamma and unassigned dbaeumer Apr 25, 2016
@egamma egamma removed the bug Issue identified by VS Code Team member as probable bug label Apr 25, 2016
@egamma
Copy link
Member

egamma commented Apr 25, 2016

Moving to Salsa for investigation.

@egamma
Copy link
Member

egamma commented Apr 25, 2016

This issue was moved to microsoft/TypeScript#8281

@egamma egamma closed this as completed Apr 25, 2016
@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
None yet
Projects
None yet
Development

No branches or pull requests

5 participants