title: React observable epic with Redux Toolkit and Typescript
body: <p>I'm not sure how to write a React observable epic with Redux Toolkit and Typescript.</p>
  <p>Suppose I have this authSlice:</p>
  <pre><code>import { CaseReducer, createSlice, PayloadAction } from &quot;@reduxjs/toolkit&quot;;
  
  type AuthState = {
    token: string,
    loading: boolean,
  };
  
  const initialState: AuthState = {
    token: &quot;&quot;,
    loading: false,
  };
  
  const loginStart: CaseReducer&lt;AuthState, PayloadAction&lt;{username: string, password: string}&gt;&gt; = (state, action) =&gt; ({
    ...state,
    loading: true,
    token: &quot;&quot;,
  });
  
  const loginCompleted: CaseReducer&lt;AuthState, PayloadAction&lt;{token: string}&gt;&gt; = (state, action) =&gt; ({
    ...state,
    loading: false,
    token: action.payload.token,
  });
  
  const authSlice = createSlice({
    name: 'auth',
    initialState,
    reducers: {
      loginStart,
      loginCompleted,
    },
  });
  
  export default authSlice;
  </code></pre>
  <p>and this store:</p>
  <pre><code>import { configureStore } from '@reduxjs/toolkit';
  import { combineEpics, createEpicMiddleware } from 'redux-observable';
  import authEpic from './epics/authEpic';
  import authSlice from './slices/authSlice';
  
  const epicMiddleware = createEpicMiddleware();
  
  export const rootEpic = combineEpics(
    authEpic
  );
  
  const store = configureStore({
    reducer: {
      auth: authSlice.reducer,
    },
    middleware: [epicMiddleware]
  });
  
  epicMiddleware.run(rootEpic);
  
  export type RootState = ReturnType&lt;typeof store.getState&gt;;
  export default store;
  </code></pre>
  <p>how should I write this authEpic (I hope the purpose is self-explanatory):</p>
  <pre><code>import { Action, Observable } from 'redux';
  import { ActionsObservable, ofType } from 'redux-observable';
  import { ajax } from 'rxjs/ajax';
  import { switchMap } from 'rxjs/operators';
  import authSlice from '../slices/authSlice';
  
  export default (action$: ActionsObservable&lt;???&gt;) =&gt; action$.pipe(
    ofType(???), /* should be of type loginStart */
    switchMap&lt;???,???&gt;(action =&gt; ajax.post( // should be from a loginStart action to {token: string}
      &quot;url&quot;, {
        username: action.payload.username, 
        password: action.payload.password 
      }
    )),
    ...
  );
  </code></pre>
  <p>I'm totally confused about the ??? that is what should be the types and how redux observable should be linked with redux toolkit.</p>
  <p>Any hint?</p>