I'm currently working on a project that involves using TypeScript and Vue with Vuex. I've encountered an error in VSCode that says:
Property '$store' does not exist on type 'ComponentPublicInstance<{}, {}, {}, { errors(): any; }, { eliminarError(error: string): void; }, EmitsOptions, {}, {}, false, ComponentOptionsBase<{}, {}, {}, { errors(): any; }, { eliminarError(error: string): void; }, ... 4 more ..., {}>>'
In my attempt to resolve this issue, I consulted the documentation, which advised me to create a d.ts file with the following content:
// vuex.d.ts
import { ComponentCustomProperties } from 'vue'
import { Store } from 'vuex'
declare module '@vue/runtime-core' {
// declare your own store states
interface State {
count: number
}
// provide typings for `this.$store`
interface ComponentCustomProperties {
$store: Store<State>
}
}
Despite implementing this solution, I still face another issue where VSCode complains that
'ComponentCustomProperties' is defined but never used
, and the initial error persists. How can I go about resolving these issues?