Problems using meteor with VSCode

Hi.

I’m been struggling with using meteor with visual studio code, the real problem that annoys me is that intellisense breaks when using absolute imports instead of relative imports:

Eg. using:

import Collections from '/imports/collections/collections.js'

instead of:

import Collections from '../../collections/collections.js'

I prefer using absolute paths because when the project gets bigger, the relative paths get bigger too, and becomes a messy thing.
Has anyone made the meteor absolute import path work with VSCode intellisense (including go to definition)? I’ll really appreciate your help.
Until now I just made this work using the absolute path, but whithout the root slash:

Eg. This works with intellisense and go to definition:

import Collections from 'imports/collections/collections.js'

But in this way, the imports doesn’t work with meteor.

ps. sorry for my bad english

4 Likes

I’m having this same issue. Have you found a solution yet?

I was just going to try VS code out but if I can’t use absolute paths, forget it.

Sadly, no.

I open an issue in the vscode repository https://github.com/Microsoft/vscode/issues/31408 but they gave me an answer about how to configure paths alias, but the problem is that vscode seems to not play well with the root slash in the path (it seems that is treated as a relative path).

Anyway, I had to return to webstorm, that, although slower, I can use the paths as I want.

Today a solution has been merged into the Typescript master: https://github.com/Microsoft/TypeScript/pull/27980

2 Likes

For those who try to make it work. Assuming basic project structure, your jsconfig.json file must contain the following lines:

{
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "/*": ["./*"]
        }
    }
}
1 Like

Excuse me all, How to autocomplete Meteor in VSCode?

You may try these extensions: Meteor, Meteor snippets.