cmcaboy / redux-typed

Code for youtube tutorial
70 stars 37 forks source link

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

Open edtalmadge opened 4 years ago

edtalmadge commented 4 years ago

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.

sprour commented 4 years ago

Yes, I get the same error