添加绝对导入后 VSCode 自动导入中断NextJS + Typescript 项目

问题描述

我最近从事的 NextJS 项目之一变得很复杂,一些文件导入路径看起来非常混乱,即 import { AuthHelper } from '../../../lib/auth

我决定使用 absolute imports解决这个问题,所以我的导入现在看起来像 import { AuthHelper } from '@/lib/auth'

自从更改了我的 tsconfig 自动导入后,我的 VSCodenvim 设置都被破坏了。

{
  "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"
  ]
}

我已尝试将 "typescript.preferences.importModuleSpecifier": "non-relative" 更改为 non-relativeauto,但自动导入仍然不起作用。

我还有什么遗漏吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)