0

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?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
ZebraK
  • 159
  • 1
  • 12
  • Does the error occur in Phpstorm or on build too? Try to move `import`s inside `declare`, this seems to be a known issue. – Estus Flask Aug 18 '22 at 20:32
  • Have you tried to disable ESLint by putting `/* eslint-disable */` at the first line? – Raeisi Aug 18 '22 at 20:44
  • Error occurs only in PhpStorm, build is correct. I cannot disable eslint because when vuex.d.ts file exists type for store not working when I imports store inside script files. – ZebraK Aug 18 '22 at 20:56
  • looks similar to https://stackoverflow.com/questions/65150323/vue-js-3-export-createstore-was-not-found-in-vuex; if the tips from this post don't help, please share a project the issue can be repeated with – lena Aug 26 '22 at 18:08

1 Answers1

0

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

"exclude": [
   "node_modules"
]
ZebraK
  • 159
  • 1
  • 12