Typing large action function extractions #555
-
Hi! 👋 I have some actions that are getting very long that I would like to extract to a function. Unfortunately, I cannot find a way to properly type I could create new actions that are called by the main actions, but they should be module-level private and not able to be externally called. Unfortunately, this function is rather complex, so returning state changes is not reasonable in this situation. What types do when your store logic starts getting out of hand and it needs to be extracted for simplicity? For example: export const useStore = defineStore({
actions: {
doSomeLongAction(info: Something) {
if (this.x) {
longFunction(this, info)
} else {
anotherLongFunction(this, info)
}
}
}
})
function longFunction(store: ???, info: Something) {
} What is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You should be able to do: function longFunction(store: ReturnType<typeof useStore>, info: Something) {
} Note you can also split into smaller actions. |
Beta Was this translation helpful? Give feedback.
You should be able to do:
Note you can also split into smaller actions.