None of the answers satisfied me. I did some digging and found this little gem. Inside of my store.ts
file, I merely add:
declare module "@vue/runtime-core" {
interface ComponentCustomProperties {
$store: Store<State>;
}
}
So it looks more like this:
//store.ts
import { createStore, Store } from "vuex";
import { CustomTool, CustomListType } from "custom";
export type State = {
tool: CustomTool
list: CustomListType | null
};
export default createStore({
state: {
tool: CustomTool.Empty
list: null,
} as State,
mutations: {},
actions: {},
modules: {}
};
declare module "@vue/runtime-core" {
interface ComponentCustomProperties {
$store: Store<State>;
}
}
Using vue3 and typescript 4.4.