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 doesn't work without a jsconfig.json after 0.10.10 #3936

Closed
gregvanl opened this issue Mar 9, 2016 · 10 comments
Closed
Assignees
Labels
important Issue identified as high-priority upstream Issue identified as 'upstream' component related (exists outside of VS Code) verified Verification succeeded
Milestone

Comments

@gregvanl
Copy link

gregvanl commented Mar 9, 2016

I found this going through the /docs/runtimes/Node.js walkthrough after seeing a doc feedback verbatim saying that typings weren't being picked up.
After creating an express application, trying to get IntelliSense for node and express types fails.
If I roll-back to 0.10.8, the typings are picked up correctly.
The generated express app does not include a jsconfig.json file.

@gregvanl
Copy link
Author

gregvanl commented Mar 9, 2016

This may be a simple repro for #3791

@gregvanl
Copy link
Author

gregvanl commented Mar 9, 2016

I got it working again by adding a jsconfig.json to the root with the module attribute set:
{
"compilerOptions": {
"module": "commonjs"
}
}
We'll need to update the Node.js walkthrough if this becomes a necessary step. microsoft/vscode-docs#221

@trstringer
Copy link
Contributor

👍 I just ran into this same problem and adding jsconfig.json and restarting VS Code indeed fixed IntelliSense. Is this by design?

@egamma
Copy link
Member

egamma commented Mar 10, 2016

This is the underlying issue microsoft/TypeScript#7292, that is, the default of the module type when you have no jsconfig.json was changed by accident, this will be fixed for TS 1.9. For now the work around is to add a jsconfig.json.

@egamma egamma closed this as completed Mar 10, 2016
@tonyfi
Copy link

tonyfi commented Mar 10, 2016

I run into the same problem. After adding jsconfig.json IntelliSense is working. However warnings are not displayed. For example, if we pass a string parameter instead of number as shown in the Node.js walkthrough there is no warning.

@egamma
Copy link
Member

egamma commented Mar 10, 2016

@tonyfi We have decided to deprecate the built-in linting support in favor of existing linters like eslint or jshint. These linters are more powerful, extensible, and many of our users are already using them. We understand that if you are not using a linter already then the price for this is that you have to install a linter and configure it.

I've tried to document this in the release notes see the migration section.

@egamma egamma changed the title Typings not being picked up after installing 0.10.10 Intellisense for nodejs doesn't work without a jsconfig.json after 0.10.10 Mar 11, 2016
@egamma egamma added stable-candiate important Issue identified as high-priority upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels Mar 11, 2016
@egamma egamma added this to the March 2016 milestone Mar 11, 2016
@egamma egamma added the verified Verification succeeded label Mar 12, 2016
@egamma
Copy link
Member

egamma commented Mar 14, 2016

@tstringer actually this is by design. When you have no jsconfig.json or tsconfig.json, then each file is treated as an island. The file can have references to other files e.g. using commonjs imports and they will be considered. However, other files in the same folder like the typings folder are not considered since there is no reference to them. You can add a reference to a typings file manually using a /// reference /// <reference path="typings/node/node.d.ts" />.

VS Code 0.10.8 used a slightly different semantics. When there was no jsconfig.json then all files inside the workspace where considered to belong to the same project. Now that TypeScript supports hybrid projects of JS and TS files, it is no longer an option to have different project semantics and you now always get the TypeScript semantic.

Bottom line you should always add a jsconfig.json to define the project context and its excluded files. This will give you reference searches, Intellisense etc.

For March we have added some hinting UI to guide the user to create a jsconfig.json.

@trstringer
Copy link
Contributor

@egamma Thanks so much for the information! Just to clarify, is this no longer considered a bug or accidental-break? And if that's the case, for JavaScript projects/applications going forward, the correct approach would be to create the jsconfig.json file in the project root 100% of the time?

Likewise, if this is the intended behavior, is this documented? I couldn't find any documentation explaining this prior to my initial comment.

Thanks so much in advance for your time!! When I get my head wrapped around the intention and future of this, I'll make an addendum to a blog post I released about this.

@egamma
Copy link
Member

egamma commented Mar 16, 2016

@tstringer correct, this is as designed. Salsa doesn't automatically pick up .d.ts files.

In almost all the cases a jsconfig.json is the right thing to do. We need to document the difference between a js project without a jsconfig.json and one that has a jsconfig.json. I've create microsoft/vscode-docs#233 to track this.

@trstringer
Copy link
Contributor

@egamma Perfect! Thanks! I'll go ahead and update my blog post so it doesn't mislead readers into thinking it is "broken" or a "bug".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
important Issue identified as high-priority upstream Issue identified as 'upstream' component related (exists outside of VS Code) verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants