As you can see above, we get intellisense to let us know that commit and dispatch take strings as the first argument, but we don’t get a list of registered actions and mutations. There is not much we can do here, with or without TypeScript. However, there are lots of third-party packages trying to get the types right in the Vuex store and modules.

We won’t be introducing new dependencies to a project only to get the types right, as most people are using just Vuex. However, vuex-class, vuex-typescript and vuex-module-decorators are worth mentioning third-party packages assisting Vuex stores.

The next version of Vuex would be built with an API which plays well with TypeScript.

We cannot do much with committing mutations and dispatching actions due to limitations in the TypeScript API for Vuex. Though with namespaced modules, we can limit the scope of a store and keep individual store modules comprehendible. However, there is another area of Vuex which can use types and intellisense.

Using Vuex Store in Vue components