-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
separating getters and actions to dedicated files break typing of this
#343
Comments
You have to put the getters and actions inlined on the |
@posva So the only thing I could do is breaking a gigantic store into small ones? Thanks! |
You will have to manually type Some of them can be inferred with |
you can also split a store into multiple stores |
Hi @posva, if it's not too much to ask, can you provide an example (or even include it in the documentation) of how to properly type |
I was able to get this done this way: type Getters = {
[Property in keyof typeof getters]: ReturnType<typeof getters[Property]>
} // Maps your getters to their return types
type Actions { ... }; // The type definition for your actions
export const actions: Actions & ThisType<typeof defaultState & Getters & Actions> = { ... };
defineStore('id', { state: () => defaultState, getters, actions }); |
I want to separate my getters and actions to dedicated files instead of just put them all together in one store file, like this:
But in the getters and actions file, I can not use
this
to reference the store object now.What should I do for such a situation?
Thanks!
The text was updated successfully, but these errors were encountered: