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

Intellisense for nodejs required packages. #957

Closed
abhilashsajeev opened this issue Dec 3, 2015 · 27 comments
Closed

Intellisense for nodejs required packages. #957

abhilashsajeev opened this issue Dec 3, 2015 · 27 comments
Assignees
Labels
feature-request Request for new features or functionality javascript JavaScript support issues
Milestone

Comments

@abhilashsajeev
Copy link

var express = require('express');

var app = express();

var port = process.env.PORT || 3000;

app.listen(port);

In the following code I required express but when I enter app and press crtl + space it shows no suggestions.

It would be nice to have code assist for installed packages because nodejs developers always play with packages.

@jrieken jrieken added the feature-request Request for new features or functionality label Dec 3, 2015
@SamVerschueren
Copy link
Contributor

@jrieken Is this possible to implement without something like a (typescript) definition file?

@jrieken
Copy link
Member

jrieken commented Dec 3, 2015

very hard. behind the scenes we just the typescript compiler to drive JS. There is a branch in TS that adds deep understanding of commonjs modules. Once we have adopted that we will be better off.

@SamVerschueren
Copy link
Contributor

Good to know :).

@abhilashsajeev
Copy link
Author

As vscode is marketed as a nodejs IDE I think it is very important to add this support. This will make Webstorm has this kind of support but its too heavy.

@SamVerschueren
Copy link
Contributor

I never saw VS Code marketed as an IDE to be honest, but maybe I just missed that :). In my opinion, VS Code is an enhanced text editor, just like Atom or Sublime Text. If you want an IDE, go for Visual Studio, Eclipse, Webstorm, etc. ;)

Apart from that, it would be very nice to have this. I was only asking @jrieken if it was possible as I was interested in the technology behind it and to how it can be accomplished.

@abhilashsajeev
Copy link
Author

@SamVerschueren
vs
That is in the home page.

I think having this feature will be of great advantage for vs code compared to other editors.

@jrieken
Copy link
Member

jrieken commented Dec 3, 2015

In full agreement - VS Code should have the best JS support you can get, like the same is true for TS, C#, go you name it.

As of today our JS support is a little rusty, incomplete, and buggy. The TS team works on better support for plain JS and once they are ready we will jump on it.

@SamVerschueren The details are crazy ;-) We take JS code, create a copy with TS-constructs on the fly, pass that to the TS compiler, and map the results back to original JS code. This guy for instance takes require('foo').toString() and generates something like import * as $$foo;\n$$foo.toString() to make TS types flow better.

@abhilashsajeev
Copy link
Author

@jrieken : So the support for this feature will take some time to implement.

@SamVerschueren
Copy link
Contributor

@jrieken So type definitions won't be necessary anymore in the future as they can be generated on the fly? Or will tsc still need them?

@jrieken
Copy link
Member

jrieken commented Dec 3, 2015

depends... Even if tsc understands this

module.exports.foo = function(a, b, c) {
   return a * b;
}

to be a module that exports a member foo of type function you will need to help it out the types of the parameters. They cannot be inferred by TS. That's why there are d.ts-files

@jrieken
Copy link
Member

jrieken commented Dec 3, 2015

@abhilashsajeev The TS team is working on this since a while and close to finish

@jrieken
Copy link
Member

jrieken commented Dec 3, 2015

All details in here: microsoft/TypeScript#4789

@abhilashsajeev
Copy link
Author

@jrieken 👍 Thats great! as long as this comes out I would completly switch my node.js devs to vs code. Hope to have this by end of year.

@egamma egamma modified the milestone: Backlog Dec 10, 2015
@jrieken jrieken added the javascript JavaScript support issues label Dec 22, 2015
@sarbbottam
Copy link

Is there any update on this, microsoft/TypeScript#4789 has been fixed.

@egamma
Copy link
Member

egamma commented Mar 8, 2016

@sarbbottam yes, Code is now using Salsa. Currently Salsa still requires that you install .d.ts files.

@abhilashsajeev Once you do tsd install express node then you get nice Intellisense:

image

@sarbbottam
Copy link

Thanks @egamma. Is there no way to get intellisense with out tsd files?
If I have to depend on tsd I did not require salsa. Not sure what benefit salsa has brought with this regard.

@SamVerschueren
Copy link
Contributor

// Offtopic
tsd is deprecated in favor of typings.

@egamma
Copy link
Member

egamma commented Mar 8, 2016

@SamVerschueren correct, and we have already updated our docs.

@SamVerschueren
Copy link
Contributor

@egamma nice 👍

@egamma
Copy link
Member

egamma commented Mar 8, 2016

@sarbbottam

Thanks @egamma. Is there no way to get intellisense with out tsd files?

Pls see https://code.visualstudio.com/Updates#_languages-javascript for scenarios where you do not need .d.ts files, but the type information that isn't in JS has to come from somewhere, e.g. JSDoc comments.

@NickGrease
Copy link

Can someone please tell me if this is supposed to work? I've spent the entire day reading just about everything I can - which was a mistake, because I'm pretty sure no one on the planet has the same answer - yes,no,with d.ts,without d.ts, typings, dst, .jsconfig, .tsconfig, user settings, etc - not one straight answer.

Sorry.

@SamVerschueren
Copy link
Contributor

Yes that works, but it seems that module.exports.generateCanvas should be exports.generateCanvas. This seems to be a bug because they are equivalent. If you add internal documentation, that documentation is also attached to the intellisense.

intellisense

Some notes to take into account.

  • This is only the case for VS Code 0.10.11 (fixed in the insiders build and in the next release). When you require file1.js in a new file, it does not provide intellisense right away, it has to reload the project first by closing and reopening the project.
  • module.exports does not work for intellisense. Will create an issue for that.

@SamVerschueren
Copy link
Contributor

Issue created #4943

@NickGrease
Copy link

@SamVerschueren I was a bit frustrated previously, so thank you for your time. I am using the Insider edition, and the code you wrote does indeed work. At some point yesterday in my attempt to fix my issue, I had downloaded typings, and installed several (node,browserify) d.ts files to my original project, and the fix you proposed above didn't work until I deleted the typings folder in my project. However, I couldn't duplicate that behavior in a new project. I'm happy just to get intellisense working again, so thanks for helping me out.

@jrieken
Copy link
Member

jrieken commented Apr 28, 2016

Closing this as we have moved to project Salsa. Let's discuss new issues separately.

@jrieken jrieken closed this as completed Apr 28, 2016
@shakvaal
Copy link

@jrieken Could you please provide a link?

@jrieken
Copy link
Member

jrieken commented Jun 24, 2016

Salsa is part of TypeScript (basically the allowJs flag): https://github.com/Microsoft/TypeScript

@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
feature-request Request for new features or functionality javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

7 participants