You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gives us a type for incrementAsync of const incrementAsync: (amount: number) => (dispatch: Dispatch) => Promise<number> which infers the thunk return type properly.
Probably consider this more of a feature request, but it would be neat if there were a pattern that could support both the return type & parameter type inference here.
The text was updated successfully, but these errors were encountered:
Yeah, it's a bit of a tradeoff. You should be able to do AppThunk<Promise<MyData>> for those cases where you need the promise result.
That said, this really isn't an issue that's specific to the template itself - it's more about documenting ways to use thunks with TS, which is better suited for the core Redux repo. If you can file a PR to update the core docs, I'd appreciate it. Thanks!
Using the AppThunk type, I may write some thunk that returns a promise:
But,
AppThunk
does not seem to infer the return type here, and just usesvoid
. So,incrementAsync
gets a type of(amount: number) => AppThunk<void>
.Using a classic signature like
gives us a type for
incrementAsync
ofconst incrementAsync: (amount: number) => (dispatch: Dispatch) => Promise<number>
which infers the thunk return type properly.Probably consider this more of a feature request, but it would be neat if there were a pattern that could support both the return type & parameter type inference here.
The text was updated successfully, but these errors were encountered: