8

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);

enter image description here

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?

7
  • 1
    Did you import typings of Vuex? Commented Aug 2, 2017 at 13:06
  • @scokmen not manually if that is an additional step. @types/vuex does not appear to be a repository. Have you tried installing types for vuex? Commented Aug 2, 2017 at 13:24
  • 1
    I did not try. There should be a types directory in "node_modules/vuex". Is it missing? Commented Aug 2, 2017 at 14:32
  • No, types are there. But then it does not seem to use them automatically? Commented Aug 3, 2017 at 6:10
  • Oh, now I see! I only had to copy them into my working directory. Thank you! Do you want to write this as an answer to collect some of those sweet sweet internet points? Commented Aug 3, 2017 at 6:17

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.