VSCode auto imports broke since adding absolute imports (NextJS + Typescript project)

687 Views Asked by At

One of the NextJS projects I've been working on recently has become complex and some of the file import paths were looking extremely messy, i.e. import { AuthHelper } from '../../../lib/auth

I decided to use absolute imports to get around this, so my imports now look like import { AuthHelper } from '@/lib/auth'.

Since changing my tsconfig auto imports have broken inside of my VSCode and nvim setups.

{
  "compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "@/*": ["./*"]
    },
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "strictNullChecks": true,
    "noImplicitAny": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

I've tried changing "typescript.preferences.importModuleSpecifier": "non-relative" to both non-relative and auto but auto importing still doesn't work.

Am I missing anything else?

0

There are 0 best solutions below