I’m trying to get module path aliases clickable in vscode
// Ctrl+click Working fine
import Layout from "src/components/layout/Layout";
// Not working
import SEO from "@components/SEO";
My JSconfig.json file
{
"compilerOptions": {
"jsx": "react",
"baseUrl": ".",
"paths": {
"@components/*": ["/src/components/*"],
"@sections/*": ["/src/sections/*"],
"@assets/*": ["/src/assets/*"]
}
}
}
I have tried everything without success
2
Answers
Here is the solution
Had same issue with ‘Go to definition’. And on the end I found it was not working for me because I had both tsconfig.json and jsconfig.json in the project.
Seems when tsconfig.json is present, alias setting from jsconfig.json are ignored.
As I want gradually convert stuff into Typescript, but have lot of .js files I kept
tsconfig.json
, and added"**/*.js"
to the"include"
list, so it sees also .js files. Now aliases in vscode are clickable.tsconfig.json: