cmcaboy / redux-typed

Code for youtube tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How could a thunk action creator be dispatched from another thunk action creator?

edtalmadge opened this issue · comments

For example, in the file: src/actions/expenses.ts
Let's say that I add an "alert" action creator to that file. And, alert is a thunk.
How could I dispatch alert from startAddExpense without raising a TypeScript error?
Is there a new type or interface that could be added to actions.ts?

When I add dispatch(alert()); to startAddExpense, I get the error:
`Argument of type '(dispatch: Dispatch, getState: () => CombinedState<{ foo: IFooReducer; bar: IBarReducer; }>) => Promise<...>' is not assignable to parameter of type 'AppActions'.

I've been experimenting with adding different types to AppActions, but haven't found the right recipe so far.

Yes, I get the same error