title: Testing redux async actions with Typescript
body: <p>Hey guys I am trying to test my async actions creators with Typescript but I am getting a type error that I cannot manage to solve.</p>
  
  <p>This is my actions: </p>
  
  <pre><code>export const loadCurrentUserRequest = () =&gt; ({
    type: LOAD_CURRENT_USER_REQUEST
  })
  
  export const loadCurrentUserSuccess = (payload: any) =&gt; ({
    type: LOAD_CURRENT_USER_SUCCESS,
    payload
  })
  
  export const loadCurrentUserFailure = (payload: any) =&gt; ({
    type: LOAD_CURRENT_USER_FAILURE,
    payload
  })
  </code></pre>
  
  <p>And this is my async action creator: </p>
  
  <pre><code>export const loadCurrentUser = () =&gt; {
    return async (dispatch: Dispatch&lt;any&gt;) =&gt; {
      dispatch(loadCurrentUserRequest())
      try {
        const response = await get(`api/currentuser`)
        if (!response.ok) {
          dispatch(loadCurrentUserFailure({ type: null, message: 'error' }))
        } else {
          const json = await response.json()
          dispatch(loadCurrentUserSuccess(json))
        }
        return response
      } catch (err) {
        dispatch(loadCurrentUserFailure({ type: err.name, message: err.message }))
        logError(err.name, err.message)
        return err
      }
    }
  }
  </code></pre>
  
  <p>The 'get' function is a middleware I've created to handle 'fetch' GET call (it adds some stuff into the header etc).</p>
  
  <p>This is my test: </p>
  
  <pre><code>  it('create an action to load the current user', () =&gt; {
      const middlewares = [thunk]
      const mockStore = configureMockStore(middlewares)
      const store = mockStore()
      const expectActions = [{ type: LOAD_CURRENT_USER_REQUEST }]
  
      store.dispatch(actions.loadCurrentUser())
      expect(store.getActions()).toEqual(expectActions)
    })
  </code></pre>
  
  <p>I am getting this error in my console:</p>
  
  <pre><code>Argument of type '(dispatch: Dispatch&lt;any&gt;) =&gt; Promise&lt;any&gt;' is not assignable to parameter of type 'AnyAction'.
    Property 'type' is missing in type '(dispatch: Dispatch&lt;any&gt;) =&gt; Promise&lt;any&gt;' but required in type 'AnyAction'.
  </code></pre>
  
  <p>I am not sure what I have done wrong here, I looked at the redux example way to test async action creators and this is similar. I can't figure where my issue is coming from.</p>
  
  <p>I do know that I will have to mock my <code>fetch</code> API calls and update my <code>expectActions</code> variable but the code isn't compiling because of that.. </p>