vuejs / vuex

🗃️ Centralized State Management for Vue.js.
https://vuex.vuejs.org
MIT License
28.4k stars 9.56k forks source link

vite 创建vue项目,安装vuex后vscode报错,Could not find a declaration file for module 'vuex'. #2223

Open WakerCN opened 1 year ago

WakerCN commented 1 year ago

使用npm init vue@latest安装的vue项目, 安装vuex后 store引入vuex,ts报错

Could not find a declaration file for module 'vuex'. 'g:/dg-b-front/node_modules/vuex/dist/vuex.mjs' implicitly has an 'any' type. There are types at 'g:/dg-b-front/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)

image

dungtv1291 commented 1 year ago

same issue . Has anyone fixed it yet?

WakerCN commented 1 year ago

@dungtv1291 you can look this issue issues/2213 it seem vuex not maintain anymore you can manual change file package.json in path node_modules\vuex\package.json and add this image

dungtv1291 commented 1 year ago

fixing it in the node_modules folder is not a good idea

masaha03 commented 1 year ago

Here is my workaround: https://github.com/vuejs/vuex/issues/2213#issuecomment-1592267216

JessicaFan commented 1 year ago

@dungtv1291 you can look this issue issues/2213 it seem vuex not maintain anymore you can manual change file package.json in path node_modules\vuex\package.json and add this image

Although fixing it in the node_ modules folder is not a good idea, but. it does work. Many thxs

liangliao-igc commented 1 year ago

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

Ribeiro-Tiago commented 6 months ago

I fixed this with a d.ts file, on my src/ directory

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";
}