title: Error on code using createAsyncThunk in Typescript
body: <p>I'm trying to create a react app using Typescript and after a bunch of errors starting to regret about this decision lol. It's much more verbose than using JS/Babel.</p>
  <p>But let's go for the real problem. I've created this custom hook:</p>
  <p>useGetDeviceById.ts</p>
  <pre><code>import { useEffect } from 'react';
  import { useHistory, useParams } from 'react-router-dom';
  import { useAppDispatch, useAppSelector } from 'src/hooks';
  import { fetchStatus } from 'src/shared/constants';
  import { getDeviceById } from 'src/features/device/redux/deviceOperations';
  import { getDevice, getDeviceFetchError } from 'src/features/device/redux/deviceSelectors';
  
  const useGetDeviceById = () =&gt; {
    const dispatch = useAppDispatch();
    const { push } = useHistory();
    const { deviceId } = useParams&lt;{deviceId?: string}&gt;();
  
    const device = useAppSelector(getDevice);
    const hasGetError = useAppSelector(getDeviceFetchError);
    const isDeviceLoading = device.fetchStatus.getProposalById !== fetchStatus.fulfilled;
    
    useEffect(() =&gt; {
      if (hasGetError) push('/');
      else {
        dispatch(getDeviceById(deviceId));
      }
    }, [push, hasGetError, dispatch, deviceId]);
  
    return { device: { ...device, deviceId }, isDeviceLoading}
  };
  
  export default useGetDeviceById;;
  </code></pre>
  <p>deviceOperations.ts</p>
  <pre><code>import { createAsyncThunk } from '@reduxjs/toolkit';
  import { loaderActions } from '../../../features/loader/redux';
  import deviceManager from '../deviceManager';
  
  export const getDeviceById = createAsyncThunk(
    'device/GET_DEVICE_BY_ID',
    async (deviceId: number, { dispatch }) =&gt; {
      dispatch(loaderActions.start('getDeviceById'));
      try {
        const device = await deviceManager.getDeviceById(deviceId);
        return { ...device, deviceId };
      } finally {
        dispatch(loaderActions.stop('getDeviceById'));
      }
    }
  );
  </code></pre>
  <p>I'm getting the error below on <code>dispatch(getDeviceById(deviceId));</code>:</p>
  <pre><code>Argument of type 'AsyncThunkAction&lt;any, number, {}&gt;' is not assignable to parameter of type 'AnyAction'.
    Property 'type' is missing in type 'AsyncThunkAction&lt;any, number, {}&gt;' but required in type 'AnyAction'.  TS2345
  
      18 |     if (hasGetError) push('/');
      19 |     else {
    &gt; 20 |       dispatch(getDeviceById(deviceId));
         |                ^
      21 |     }
      22 |   }, [push, hasGetError, dispatch, deviceId]);
      23 |
  </code></pre>
  <p>Can you help me? Is it the correct way to create this stuff?</p>