How to deal with typescript with property from pinia plugin in computed #2270
-
Hey 👋 Here is a basic store example with a plugin to understand my question pinia.use(() => ({ taxe: ref(2) })); Store: const useMyStore = defineStore('my-store', () => {
const self = useMyStore();
const price = computed(() => 3 + self.taxe);
return { price };
}); You can test it here: https://stackblitz.com/edit/vitejs-vite-sp4xr8?file=src%2FApp.vue So my question is how to deal with this error because as you can see on stackblitz the price is calculated correctly but typescript isn't happy and now my store is typed as |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This is not possible to type because types are recursive (the error you see) I would suggest not to put the tax in a plugin but rather in a global variable or a store if needed |
Beta Was this translation helpful? Give feedback.
-
well, in my case it's a bit more complicated, but thanks for the quick reply! |
Beta Was this translation helpful? Give feedback.
This is not possible to type because types are recursive (the error you see)
I would suggest not to put the tax in a plugin but rather in a global variable or a store if needed