-
Notifications
You must be signed in to change notification settings - Fork 137
Closed
Description
Line 9 in 1df7cf6
| export type BoundAction = () => void; |
I'm looking into use cases for Unistore where I need to expose the store and bound actions for use in other frameworks. I've been taking advantage of store.action() to get a handle on that bound action, but I get typing issues when that action takes parameters due to how BoundAction is defined.
For example when I...
// define the action as an unary function
const actions = {
toggleLoading: (_state: MyState, isLoading: boolean) => ({ isLoading })
}
// and then get the bound action from our previously created store
const toggleLoading = store.action(actions.toggleLoading)
// I receive: TS2554: Expected 0 arguments, but got 1.I have temporarily sidestepped this issue by locally redefining BoundAction to be:
export type BoundAction = (...args: any) => void;I'm a TypeScript newbie so I don't have good sensibilities when it comes to typing yet. Is there a 'better' way to type this, or am I doing something wrong?
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels