VSCode autoimport not working after using absolute imports in NextJS

Viewed 2556

my VSCode auto import(using control + space) is not working after I created a jsconfig.json file in my NextJS project.

This is my json:

{
  "compilerOptions": {
    "baseUrl": "."
  },
  "include": ["."]
}

I'm using next 10.2.3 and vscode 1.57.1. If I remove the jsconfig.json file, auto import works just fine..

Someone knows why?

4 Answers

I think you need to add extensions as well. Here's how my app is using it, and I'm getting auto import suggestions correctly.

"baseUrl": ".",
"include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],

Sometimes when auto import stops working, I do command palette -> reload project and it'll be fixed. Note that "reload project" is not "reload window", it's much faster.

I had the same problem after an update from vscode to version 1.57, I believe it's a problem in the version, because when I change it to 1.56 it works normally.

In case you trying to auto import .js files , you need to add this : "**/*.js" to the include array inside tsconfig.json file

Related