vue3.x 里面使用 vuex4.x 无法找到模块“vuex”的声明文件

报错如下

解决

https://github.com/vuejs/vuex/issues/2223

https://github.com/vuejs/vuex/issues/2213#issuecomment-1592267216

我使用了这个方式处理

在根目录新建一个 vuex.d.ts 文件

ts 复制代码
declare module "vuex" {
    export * from "vuex/types/index.d.ts";
    export * from "vuex/types/helpers.d.ts";
    export * from "vuex/types/logger.d.ts";
    export * from "vuex/types/vue.d.ts";
}


tsconfig.app.json 配置文件里面添加这个文件

json 复制代码
{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "compilerOptions": {
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
    "types": ["vite/client"],
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "erasableSyntaxOnly": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedSideEffectImports": true
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "vuex.d.ts"
  ]
}
相关推荐
小云小白9 天前
高性能 v-html 弹窗实现:Vue3 + Element Plus 最佳实践
vue3·弹窗·v-html
xun-ming10 天前
SpringBoot和Vue3实战阿里百炼大模型极简版
spring boot·ai·vue3·智能体·百炼大模型
哆啦A梦158811 天前
20, Springboot3+vue3实现前台轮播图和详情页的设计
javascript·数据库·spring boot·mybatis·vue3
小盼江11 天前
基于Springboot3+Vue3的协同过滤鲜花商城推荐系统
vue3·springboot3·鲜花商城
哆啦A梦158811 天前
11,Springboot3+vue3个人中心,修改密码
java·前端·javascript·数据库·vue3
哆啦A梦158812 天前
01, 前端vue3框架的快速搭建以及项目工程的讲解
前端·vue3·springboot
萧曵 丶16 天前
Vue3组件通信全方案
前端·javascript·vue.js·typescript·vue3
Json____16 天前
vue3-商城管理系统-前端静态网站
前端·vue3·ts·商城纯静态
吴声子夜歌21 天前
Vue3——网络框架Axios的应用
javascript·vue3·axios
赵庆明老师1 个月前
vben开发入门6:tsconfig.json
json·vue3·vben