vs代码导入提示不推荐下一个js别名路径

问题描述

我在我的前端项目中使用 nextjs。我必须能够从框架中导入资源,比如它的 useRouter 钩子。在这种情况下,My vs Code 只推荐以下路径导入:'next/dist/client/router'。但实际上有一条更短的路径:'next/router'。我想尽一切办法来完成这项工作。安装自动导入插件删除导入插件,更改 vs 代码上的 typescript/javascript 导入设置,修改 tsconfig.json 等。它们都不起作用。我目前的配置是:

  • 没有导入插件
  • 导入模块说明符结尾:最短
  • tsconfig.json:
{
  "compilerOptions": {
    "target": "es5","lib": ["dom","dom.iterable","esnext"],"allowJs": true,"allowSyntheticDefaultImports": true,"skipLibCheck": true,"strict": true,"forceConsistentCasingInFileNames": true,"noEmit": true,"esModuleInterop": true,"module": "esnext","moduleResolution": "node","resolveJsonModule": true,"isolatedModules": true,"sourceMap": true,"noFallthroughCasesInSwitch": true,"noUnusedLocals": true,"noUnusedParameters": true,"noImplicitAny": true,"preserveConstEnums": true,"strictnullchecks": false,"removeComments": false,"jsx": "react",// default is preserve
    "baseUrl": ".",},"include": ["next-env.d.ts","**/*.ts","**/*.tsx"],"exclude": ["dist",".next","out","node_modules","__tests__"]
}

解决方法

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

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

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