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

VS Code "Jump to definition" does not work #9

Closed
antoinerousseau opened this issue Jun 17, 2019 · 5 comments
Closed

VS Code "Jump to definition" does not work #9

antoinerousseau opened this issue Jun 17, 2019 · 5 comments

Comments

@antoinerousseau
Copy link

Any way we can make this work again? (clicking an import to go to the definition file)

@alampros
Copy link
Owner

I think this is a typescript configuration issue. In your tsconfig.json, make sure it knows how to resolve absolute paths. For example, one of mine looks like this:

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "*": [
        "types/*",
        "*"
      ]
    }
  },

Note: If you're not using typescript, make a jsconfig.json file instead (vscode uses typescript under the hood to infer types).

@antoinerousseau
Copy link
Author

Thanks @alampros, this works great!
I added a jsconfig.json (since the project is unfortunately not in TS) in the project root, with this:

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

The only details is that I now get suggestions saying

Could not find a declaration file for module 'config/constants'. '[...]/src/config/constants.js' implicitly has an 'any' type.

But nothing annoying.

@lsbyerley
Copy link

@antoinerousseau @alampros Do you know how to get rid of those suggestions? I'm using a jsconfig.json file as well and i keep seeing those suggestions when using absolute imports.

@antoinerousseau
Copy link
Author

@lsbyerley you can turn off all VS Code TS suggestions in VS code settings if you want, but I don't know how to fix only these ones.

@alampros
Copy link
Owner

Try disabling the noImplicitAny setting. See all the compiler options here: https://www.typescriptlang.org/docs/handbook/compiler-options.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants