Vuex + Typescript

空扰寡人 提交于 2019-12-08 16:45:37

问题


I am converting a JavaScript project to TypeScript. However I am getting a type error when trying to make Vue use Vuex.

import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

It looks like the problem is that vuex does not provide type definitions like vuejs does?

Because I also have to set

"allowSyntheticDefaultImports": true

in my tsconfig.json.

How can I solve this problem and make Vue.use accept Vuex as the correct type?


回答1:


I wish I had an better answer, but I ended up deleting node_modules and reinstall them. It appeared to be a mismatch between versions.

Vue / Vuex own typings did take care of everything after I ran a quick package install and upgrade.



来源:https://stackoverflow.com/questions/45459914/vuex-typescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!