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

JavaScript Intellisense not working for commonJS after upgrading to 0.10.10 #3791

Closed
sghung opened this issue Mar 7, 2016 · 24 comments
Closed
Assignees

Comments

@sghung
Copy link

sghung commented Mar 7, 2016

I updated to 0.10.10 today, hoping to try out the new JavaScript support with Salsa. Unfortunately, my Intellisense has stopped working. I am using type definition files from definitely typed (e.g. the express.d.ts).

For example, using 0.10.8:

var exp = require("express");
exp.Router

I will see the content assist for the "Router" function and I can visit the definition file by right clicking on "Router" > Go to Definition

Now when I do the same thing in 0.10.10, I don't see "Router" in the Intellisense list. In addition, the list seems to have variables I had defined earlier in my code (which doesn't apply to express at all).

@Daynil
Copy link

Daynil commented Mar 8, 2016

I have the same issue, intellisense seems to be completely missing as of 0.10.10 in javascript files. I tried introducing a skeleton jsconfig.json file:

{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
}
}

This doesn't help. I'm also using typings from tsd.

For reference, I tried the exact same setup but changed my file to .ts and tsconfig.json and intellisense worked properly as before the update.

@slowmove
Copy link

slowmove commented Mar 8, 2016

My issue seems to be related to this as well.
#3813

@konrad147
Copy link

I have same problem. Javascript intellisense stopped working after update in HTML files. In javascript files it's working fine

@Daynil
Copy link

Daynil commented Mar 8, 2016

@konrad147 Yours is expected behavior. From the patch notes:
There is no longer support for IntelliSense in script sections inside HTML documents.

@egamma
Copy link
Member

egamma commented Mar 8, 2016

@konrad147

I have same problem. Javascript intellisense stopped working after update in HTML files. In javascript files it's working fine

Sorry, but this is a know limitation that is documented in release notes. We will work with the TypeScript team to bring this back.

@egamma
Copy link
Member

egamma commented Mar 8, 2016

@sghung this works for me, pls see below. Do you have a jsconfig.json defined? Can you compare the setup in the screenshot with your setup

image

@egamma
Copy link
Member

egamma commented Mar 8, 2016

@Daynil do you have a setup that allows me to reproduce the problem.

@Ravadre
Copy link

Ravadre commented Mar 8, 2016

I have a similar problem with Javascript after updating to 0.10.10. After update it completely stopped working, forcing Intellisense to show up with ctrl+space shows "Loading..." tooltip which hangs forever. Once I got a tooltip that "[Javascript service?] crashed 5 times in 5 minutes" (are those crash reports logged somewhere so I could share them?)

Some details that maybe could be useful for establishing pattern:

Update 2: OK, I am pretty sure that I correlated the issue with VS Code trying to parse and cache existing JS folders. My folder structure looks like this:

/
- jsconfig.json
- [other config files etc.]
/ client
  / app - folder with our code
  / jspm_packages - jspm packages
/ node_modules - dev. npm packages (gulp etc.)
/ jspm_packages - old folder, which is not used right now

Opening this folder does crash Intellisense for JS files. It can be fixed with one of few ways:

  • remove jsconfig.json - VS Code does give some intellisense then, but it does not scan jspm/npm folders.
  • remove both node_modules and old jspm_packages - VS Code will start helper child process, in my case it will load about 400MB of cached data and Intellisense will work as expected.
  • exclude explicitly node_modules in jsconfig.json - This will prevent VS Code from scanning node_modules, and work similarly to previous point

To see what happens when Intellisense is broken we can observe child processes it spawns. One of child processes will try to cache files from folders I mentioned above, crash silently, new one will be spawned and so on. After few crashes VS Code will show message I mentioned before.

One thing I can't figure out to create a repro is why for some projects VS Code will cache node_modules and for some won't (without even excluding them from jsconfig.json)

Update 1: Changing jsconfig.json (by removing exclude or by changing module to different values doesn't help, same for setting it empty with { }, but removing jsonconfig.json file altogether does help.

Old post:
The problem is not machine wide, for simpler projects I have it does work well (I can have 2 instances of VS Code running side by side, one is having Intellisense, one is stuck. I do have jsconfig.json, for me it looks like that:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "ES6"
    },
    "exclude": [
        "target"
    ]
}

Making it identical to what @egamma suggested did not solve the problem.

I tried to open only small part of the project and it still hangs (by opening a folder -> pointing it to some subdirectory with 2-3 *.js files; maybe VS Code is smart enough to look up in directory tree to "base directory"?)

The project I have problem with is of rather small (around 50 js files, many of them very short) we are using AngularJS 1.5 with jspm (systemjs) and pure ES6, no TS (no tsd/typings folders are present). Our setup is maybe somewhat unusual as we are using ES6 modules to do heavy lifting when defining Angular components, something like this:

import template from './match.html!text';
import controller from './match.controller';
import link from './match.link.js';

let matchComponent = function(){
    return {
        template,
        controller,
        [...],
                link : link
    };
};

I will try to duplicate my project layout and see if I can get a minimal repro.

@ghost
Copy link

ghost commented Mar 8, 2016

I also am having problems with the intellisense now, getting that ~10s lag. It seems to happen intermittently, but it consistently happens when typing "try" or "trycatch" to get the snippet. The lag ranges from ~3-10s. I tried this in a new file in a new folder, and the lag doesn't occur. Only in my actual project.

@sghung
Copy link
Author

sghung commented Mar 8, 2016

@egamma I added the jsconfig.json as you had suggested. That did not fix the issue. However, if I restart VS Code, then intellisense works again. Are the jsconfig.json properties being cached somehow? (that would be fixed on a restart?)

@egamma
Copy link
Member

egamma commented Mar 8, 2016

@sghung

I added the jsconfig.json as you had suggested.

OK, can you confirm that you didn't have a jsconfig.json when Intellisense didn't work?

Are the jsconfig.json properties being cached somehow? (that would be fixed on a restart?)

yes, but you do not have to restart you can execute Reload JavaScript Project.

@egamma
Copy link
Member

egamma commented Mar 8, 2016

@Ravadre please notice that the jsconfig.json I included in this issue was just for this particular project setup. In general you exclude the folders with generated or library JS code, pls see https://code.visualstudio.com/Updates#_languages-javascript the section 'Migration'

Something like

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "ES6"
    },
    "exclude": [
        "node_modules",
        "jspm_packages",
        "client/jspm_packages
    ]
}

@sghung
Copy link
Author

sghung commented Mar 8, 2016

@egamma Yes, I can confirm that I did not have a jsconfig.json file in my workspace (in VS Code 0.10.8, I didn't need a jsconfig.json for intellisense to work).

Thanks for the tip regarding Reload JavaScript Project, that worked. Now to workaround this issue I do:

  1. Test Intellisense not working in project
  2. Add jsconfig.json
  3. Test intellisense not working in project
  4. Run "Reload JavaScript Project" command
  5. Test Intellisense now works in project

@Ravadre
Copy link

Ravadre commented Mar 8, 2016

@egamma Migration section, which for some reason I missed when I read changelog yesterday explains a lot. It also perfectly explains why removing jsconfig helped. I guess most time I spent on testing was futile 😞 .

Possibly, one thing I think could be useful to add would be some sort of a message to inform user that TS engine crashes because of (possibly?) running out of memory. Right now forgetting to exclude 1-2 jspm/node directories can mean that Code will constantly parse those file in the background (which means high IO, allocating lots of memory) over and over again.

Thanks for help!

@Daynil
Copy link

Daynil commented Mar 8, 2016

Here's how my setup looks when I'm getting the issue, with the jsconfig.json set up as directed by @egamma :

intellisense

@egamma egamma changed the title JavaScript Intellisense not working after upgrading to 0.10.10 JavaScript Intellisense not working for commonJS after upgrading to 0.10.10 Mar 9, 2016
@egamma
Copy link
Member

egamma commented Mar 9, 2016

@Ravadre agreed that we should provide more guidance for how to exclude folders and also in the case of a crash. This is tracked in #3901

@egamma
Copy link
Member

egamma commented Mar 9, 2016

@bill-mybiz your behaviour can be explained by not excluding folders in the jsconfig.json pls see this comment #3791 (comment).

@egamma
Copy link
Member

egamma commented Mar 9, 2016

@Daynil

I cannot reproduce what you show in the comment above (with or without jsconfig.json)
image

Can you start with the minimal example from the screenshot, does this work for you? Next, can you and more of your setup until Intellisense breaks?

Also when adding/modifying the jsconfig.json can you make sure that run the 'Reload JavaScript' command.

@ghost
Copy link

ghost commented Mar 9, 2016

@egamma This is a TypeScript project and there are no source js files in my ts files glob. But just for the fun of it, I added a jsconfig.json as follows in the root directory (alongside my tsconfig):

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "ES6"
    },
    "exclude": [
        "bin",
        "bin-webpack",
        "client/node_modules",
        "client/platforms",
        "client/plugins",
        "client/resources",
        "node_modules"
    ]
}

I tried both restart javascript project command and restarting vs code itself and there is no difference. There are still several seconds of lag with the trycatch snippet option (as well as with other ctrl+shift+spacebar intellisense). When I hit ctrl+space on "trycatch" to get the snippet intellisense option, it will consistently lag about 10sec. Ctrl+space thereafter will be immediate as long as I don't edit anything. But if I hit spacebar just after trycatch (to move the cursor off of the symbol), then left arrow (to return to the end of "trycatch"), and then ctrl+space, there will be the 10 second lag again.

I also tried to explicitly exclude folders in tsconfig, but it is not allowed when using the files glob.

My project is available on GitHub here.

@egamma
Copy link
Member

egamma commented Mar 10, 2016

@bill-mybiz since this is a TypeScript project then your issue is unrelated to what is discussed here and you are in the wrong issue 😄

I also tried to explicitly exclude folders in tsconfig, but it is not allowed when using the files glob.

I see that you are using filesGlob this attribute is not supported in TS version that is used by VS Code (fileGlob is an Atom TypeScript specific extension). I would recommend to not use files glob but have a tsconfig.json that has no files section but that uses exclude.

@ghost
Copy link

ghost commented Mar 10, 2016

@egamma Ah, yes it's always difficult to decide new issue vs. old one. I just saw that there are so many intellisense issues already and that they seemed to be swallowed by this one. I'll post a new one. Thanks!

@egamma
Copy link
Member

egamma commented Mar 10, 2016

@bill-mybiz thanks, then I'll close this one

@Daynil
Copy link

Daynil commented Mar 27, 2016

@egamma I think I finally figured out what was going wrong with my project. I had a user setting that pointed to my global the tsserver in node_modules/typescript/lib. Suddenly an error message popped up saying the path doesn't point to a valid tsserver install. When I removed the user setting it started working again. Just in case anyone has this issue.

@egamma
Copy link
Member

egamma commented Mar 27, 2016

@Daynil thanks added this to the release notes about javascript:

@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

6 participants