Skip to content

AsyncAction should accept ThunkAction or Action #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

AsyncAction should accept ThunkAction or Action #149

wants to merge 1 commit into from

Conversation

athornburg
Copy link

Overwriting default redux Dispatch type should be able to handle both the type for ThunkAction and the Type for the Redux Dispatch

Fix related to this issue:
#82

Example of a fix with a failing test:

https://github.com/codebandits/typescript-react-starter/blob/master/src/main/actions/__test__/actions.test.ts#L8-L12

Overwriting default redux Dispatch type should be able to handle both the type for ThunkAction and the Type for the Redux Dispatch 

Fix related to this issue:
#82

Example of a fix with a failing test:

https://github.com/codebandits/typescript-react-starter/blob/master/src/main/actions/__test__/actions.test.ts#L8-L12
@athornburg
Copy link
Author

athornburg commented Aug 18, 2017

Thanks @rodolfo2488 for the help!

@@ -6,7 +6,7 @@ export type ThunkAction<R, S, E> = (dispatch: Dispatch<S>, getState: () => S,

declare module "redux" {
export interface Dispatch<S> {
<R, E>(asyncAction: ThunkAction<R, S, E>): R;
<R, E>(asyncAction: ThunkAction<R, S, E> | S): R;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would asyncAction have the type of the state (i.e. S)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, shouldn't this be Action. From import { Action } from 'redux'?

@timdorr
Copy link
Member

timdorr commented May 25, 2018

This has been superseded by some other updates to the typings. If you want to revisit this, I can reopen it for you.

@timdorr timdorr closed this May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants