Why is VS Code javascript intellisense dependent on the files I have open?

Viewed 1072

I have a project using .js and .es6 files (Rails, though I don't think that matters) on which I'm trying to use VS Code's javascript intellisense per these instructions. I have a jsconfig.json file:

{
    "include": [
        "app/assets/javascripts/**/*",
        "vendor/assets/javascripts/**/*"
    ],
    "compilerOptions": {
        "target": "ES6",
        "checkJs": true
    }
}

at the root and all the javascript is in the folders mentioned in the include section. I've also created a globals.d.ts file at the root.

If I open globals.d.ts in VS Code and then run Typescript: Restart TS server, VS Code recognizes those global variables in javascript files. However if I then close globals.d.ts and run Typescript: Restart TS server again, VS Code does not recognize the globals. This also happens with global variables created in other javascript files. For example, say Class.es6 defines a class. I only get intellisense for the class if I have Class.es6 open in VS Code.

I'm not sure first why my setup isn't working, and second why it would ever depend on which files I have open at the time in VS Code.

1 Answers
Related