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 #8281

Closed
egamma opened this issue Apr 25, 2016 · 5 comments
Closed

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

egamma opened this issue Apr 25, 2016 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@egamma
Copy link
Member

egamma commented Apr 25, 2016

From @mattflix on April 24, 2016 10:6

  • 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?

Copied from original issue: microsoft/vscode#5714

@egamma egamma self-assigned this Apr 25, 2016
@egamma
Copy link
Member Author

egamma commented Apr 25, 2016

From @mattflix on April 25, 2016 1:0

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

@egamma
Copy link
Member Author

egamma commented Apr 25, 2016

From @sarbbottam on April 25, 2016 3:44

Similar issues:
microsoft/vscode#1648
microsoft/vscode#957

@egamma
Copy link
Member Author

egamma commented Apr 25, 2016

From @bpasero on April 25, 2016 9:0

@dbaeumer @egamma @jrieken fyi

@egamma
Copy link
Member Author

egamma commented Apr 25, 2016

Moving to Salsa for investigation.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 25, 2016

duplicate of #6670

@mhegazy mhegazy closed this as completed Apr 25, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Apr 25, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants