title: Redux Toolkit: How to refer action created with createAction as type
body: <p>Redux toolkit provides <code>createAction</code> helper method. I am having trouble referring actions created with <code>createAction</code> as type.</p>
  <p><strong>For example</strong>:</p>
  <pre><code>const getData = createAction&lt;PayloadAction&lt;number&gt;&gt;('user/getData')
  
  function* exampleSaga(action: ?) {
     ...
  }
  </code></pre>
  <p>How can I tell <em><code>exampleSaga</code></em> that <code>action</code> is of type <strong><code>getData</code></strong>?</p>
  <br>
  <hr>
  <p>To see how I've tried doing it, refer the below (example) code and see comments for the problem I am facing:</p>
  <p><em>reducer.ts</em></p>
  <pre><code>import { createAction, PayloadAction } from '@reduxjs/toolkit';
  
  export const getData = createAction&lt;PayloadAction&lt;number&gt;&gt;('user/getData');
  
  const userSlice = createSlice({
    name: userSliceName,
    initialState,
    reducers: {
      getUser(state: IUserState): void {
        state.loading = true;
        state.error = null;
      },
      getUserSuccess(state: IUserState, action: PayloadAction&lt;{ user: IUser }&gt;): void {
        const { user } = action.payload;
        state.user = user;
        state.loading = false;
        state.error = null;
      },
      getUserFailure(state: IUserState, action: PayloadAction&lt;string&gt;): void {
        state.loading = false;
        state.error = action.payload;
      },
    },
  });
  
  export type UserSaga = Generator&lt;
    | CallEffect&lt;IUser&gt;
    | PutEffect&lt;typeof getUserSuccess&gt;
    | PutEffect&lt;typeof getUserFailure&gt;
    | ForkEffect&lt;never&gt;
  &gt;;
  </code></pre>
  <p><em>sagas.ts</em></p>
  <pre><code>import { UserSaga, getData } from './reducer.ts';
  
  // For the following fetchUser saga arguments, how can I define that 'action' is of type getData, imported from the above 'reducer.ts' file.
  function* fetchUser(action: PayloadAction&lt;typeof getData&gt;): UserSaga {
    try {
      const userId = action.payload;
      // Problem is here
      // I expect userId to be of type number, whereas it is:
      // ActionCreatorWithPayload&lt;{payload: number, type: string}&gt;
      ...
    } catch (e) {
      ...
    }
  }
  
  function* userSaga(): UserSaga {
    const pattern: any = getData.type;
    yield takeLatest(pattern, fetchUser);
  }
  </code></pre>