How to Fix Vuex TypeScript Errors in a Vue Project

Fix missing Vuex type declarations in a TypeScript project by adding a module declaration file.
Introduction
In some Vue and TypeScript projects, the editor may report that Vuex types cannot be found. If your installed Vuex version exposes the declaration files shown below, a local module declaration can help TypeScript resolve them.
Add a declaration file
- Create a
vuex.d.tsfile in your project root (or another directory included bytsconfig.json). - Add the following declarations:
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'
}
- Restart the TypeScript server or development server so it picks up the new declaration.
If the error remains, check that the paths exist in your installed Vuex version and that the declaration file is included by your TypeScript configuration. Package declaration layouts can differ between versions.