Search code examples
typescriptvue.jsvuexphpstormwebstorm

Overwritten typing errors with vuex


I'm writing project with Vue 3 and TypeScript.

I have problem with vuex, I created a vuex.d.ts file for $store access inside Components:

import { Store } from 'vuex';
import { State } from '@/store';

declare module '@vue/runtime-core' {
    interface ComponentCustomProperties {
        $store: Store<State>
    }
}

but when this file exists i have error inside file where I'm creating store.

TS2305: Module '"vuex"' has no exported member 'createStore'.

I'm using PhpStorm, maybe there is a problem. When I click on vuex import with Ctrl this displays two type declarations. Original and my vuex.d.ts How to fix that error and have access to $store inside components?


Solution

  • There was an error in tsconfig.json, I had to remove this lines:

    "exclude": [
       "node_modules"
    ]