React Redux await dispatch in TypeScript

According to the official documentation, you define a thunk action's type as:

export const thunkSendMessage =
  // Return type, state type, extra argument type, action type
  (message: string): ThunkAction<void, RootState, unknown, AnyAction> =>
  async dispatch => {
    const asyncResp = await exampleAPI()
    dispatch(
      sendMessage({
        message,
        user: asyncResp,
        timestamp: new Date().getTime()
      })
    )
  }

However, TypeScript will complain if you await this thunk:

// 'await' has no effect on the type of this expression
await dispatch(thunkSendMessage(message))

dispatch(async (dispatch, getState) => {
  // 'await' has no effect on the type of this expression
  await thunkSendMessage(message)(dispatch, getState)
})

This is because we explicitly defined the thunk's return type as void. So let's make TypeScript infer the return type (should be a Promise for us to await) by only typing the thunk's arguments:

export const thunkSendMessage = (message: string) =>
  // State type, extra argument type, action type
  async (dispatch: ThunkDispatch<RootState, void, AnyAction>, getState: () => RootState) => {
    // ...
  }