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"
  ]
}
相关推荐
凯小默1 天前
19-项目路由规则介绍
vue3
鹤归时起雾.2 天前
Vue3响应式编程核心指南
开发语言·vue3
Beginner x_u2 天前
Vue3 + TS + TailwindCSS 操作引导组件开发逐行解析
typescript·vue3·前端开发·tailwindcss·组件开发
凯小默2 天前
17-使用前置导航守卫判断用户登录后刷新情况
vue3
凯小默2 天前
18-通过actions方法封装请求以及补充计算属性
vue3
凯小默4 天前
13-实现首页的基础结构
vue3
我叫张小白。4 天前
Vue3 插槽:组件内容分发的灵活机制
前端·javascript·vue.js·前端框架·vue3
是席木木啊4 天前
Vue3 + Axios 适配多节点后端服务:最小侵入式解决方案
vue3·axios·前端开发·技术方案设计
宁波阿成4 天前
基于Jeecgboot3.9.0的vue3版本前后端分离的flowable流程管理平台
vue3·springboot3·flowable·jeecgboot