无法找到模块“vuex”的声明文件

运行环境vue3 + Vite + TypeScript  

在导入vuex的时候

import {createStore} from 'vuex'

出现如下错误提示

无法找到模块“vuex”的声明文件。“E:/workspace/TuWenBaoDian/tuwenbaodian/tuwenbaodian.admin/node_modules/.pnpm/vuex@4.0.2_vue@3.3.9/node_modules/vuex/dist/vuex.mjs”隐式拥有 "any" 类型。
  There are types at 'e:/workspace/TuWenBaoDian/tuwenbaodian/tuwenbaodian.admin/node_modules/vuex/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'vuex' library may need to update its package.json or typings.ts(7016)

解决方法

在vite-env.s.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";
  
}

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值