Currently utilizing Vue 3 alongside Pinia; my api service is utilized for making requests to the api. I have included it as a property to ensure availability across all stores:
In my main.ts file:
import { http } from "@/services/http";
const store = createPinia();
store.use(({ store }) => {
store.http = http
})
Although everything appears to function correctly, TypeScript flags an error indicating that the http property does not exist.
Within stores/system.ts:
export const useSystemStore = defineStore("system", {
state: () => ({
data: <SystemResponse>{
...
}
}),
actions: {
connect() {
this.http.get("system") // <-- Property 'http' does not exist on type '{ connect(...
.then((response) => {
...
...
How can I resolve this issue and make TypeScript recognize it?
While scouring through Pinia's documentation, unfortunately, the solution for addressing this problem eluded me.