I was unable to find a satisfactory answer, so I took matters into my own hands and stumbled upon a fantastic solution. Inside my store.ts
file, I simply inserted the following:
declare module "@vue/runtime-core" {
interface ComponentCustomProperties {
$store: Store<State>;
}
}
This snippet transforms the code in this manner:
//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>;
}
}
This solution works perfectly with vue3 and typescript 4.4.