如何解决添加绝对导入后 VSCode 自动导入中断NextJS + Typescript 项目
我最近从事的 NextJS 项目之一变得很复杂,一些文件导入路径看起来非常混乱,即 import { AuthHelper } from '../../../lib/auth
我决定使用 absolute imports 来解决这个问题,所以我的导入现在看起来像 import { AuthHelper } from '@/lib/auth'
。
自从更改了我的 tsconfig
自动导入后,我的 VSCode
和 nvim
设置都被破坏了。
{
"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-relative
和 auto
,但自动导入仍然不起作用。
我还有什么遗漏吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。