Vue.js 3 Property '$store' does not exist on type 'CreateComponentPublicInstance

Viewed 2186

I'm using vue.js 3, typescript and vuex 4 for my project. But I got this error when using this.$store on my .vue file

Property '$store' does not exist on type 'CreateComponentPublicInstance<{}, {}, { exchanges: Exchange[]; isValidNodeUrl: boolean; isValidSelectedNetworks: boolean; web3: "" | Web3; privateKey: string; jsonKeystore: string; jsonKeystorePassword: string; ... 24 more ...; botIsRunning: boolean; }, ... 14 more ..., {}>'

I have added vuex.d.ts based on this document, but still got the same error https://next.vuex.vuejs.org/guide/typescript-support.html .

import { Store } from "vuex";
import { ComponentCustomProperties } from "vue";

import { State } from "@/interfaces/bot";

declare module "@vue/runtime-core" {
  // Declare your own store states.

  interface ComponentCustomProperties {
    $store: Store<State>;
  }
}

Can somebody help me ?

1 Answers

check the tsconfig.json. possible there is an error on cannot identify the file.try to add file again by deleting again.

Related