问题
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