Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go to definition for .jsx does not work

I am working with es6 syntax in Visual Studio Code and when I import ordinary file, then I can click F12 (Go to definition) and it works just fine. The problem is that with components (import from .jsx files) it does not work at all (nothing happens when you click go to definition). Has anyone an idea how it can be fixed?

P.S. I have jsconfig.json like that to allow proper go to definition for ordinary .js files:

{
    "compilerOptions": {
        "target": "ES6"
    },
    "exclude": [
        "node_modules"
    ]
}
like image 854
Ilya Chernomordik Avatar asked Jun 26 '17 06:06

Ilya Chernomordik


1 Answers

Although you can track down the solution from github issues mentioned in one of the comments, I wanted to make it easier for SO users. Quote from the Github issues page:

easy workaround is to add the compilerOption "jsx": "preserve" (or "jsx": "react" or "jsx": "react-native")

jsconfig.json:

{
    "compilerOptions": {
        "jsx": "react"
    }
}
like image 107
John Lee Avatar answered Sep 25 '22 16:09

John Lee