title: The thunkAPI.getState method does not correctly infer the state type
body: <p>Code here:</p>
  <p><code>users.slice.ts</code>:</p>
  <pre><code>import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
  
  const userAPI = {
    async fetchById(userId: string) {
      return { data: { id: userId, name: 'teresa teng' } };
    },
  };
  
  export const fetchUserById = createAsyncThunk&lt;User, string&gt;(
    'users/fetchByIdStatus',
    async (userId, thunkAPI) =&gt; {
      const response = await userAPI.fetchById(userId);
      return response.data;
    },
    {
      condition: (userId, { getState }) =&gt; {
        const { users } = getState();
        const { fetchStatus } = users[userId];
        if (fetchStatus === 'loading') {
          return false;
        }
      },
    }
  );
  
  interface User {
    name: string;
    id: string;
  }
  
  interface UsersSliceState {
    [id: string]: { fetchStatus: 'idle' | 'loading'; data: User };
  }
  
  const usersSliceState: UsersSliceState = {
    1: {
      fetchStatus: 'idle',
      data: { name: '', id: '' },
    },
  };
  
  const usersSlice = createSlice({
    name: 'users',
    initialState: usersSliceState,
    reducers: {},
    extraReducers: (builder) =&gt; {
      builder.addCase(fetchUserById.fulfilled, (state, action) =&gt; {
        console.log(action);
      });
    },
  });
  
  export default usersSlice.reducer;
  </code></pre>
  <p><code>store.ts</code>:</p>
  <pre><code>import { configureStore } from '@reduxjs/toolkit';
  import usersSliceReducer from './users.slice';
  
  export const store = configureStore({
    reducer: {
      users: usersSliceReducer,
    },
  });
  
  export type RootState = ReturnType&lt;typeof store.getState&gt;;
  </code></pre>
  <p><code>main.ts</code>:</p>
  <pre><code>import { store } from './store';
  import { fetchUserById } from './users.slice';
  
  store.dispatch(fetchUserById('1'));
  </code></pre>
  <p>TSC throws an error when I call <code>getState()</code> method and deconstruct the <code>users</code> state slice inside <code>condition</code> function</p>
  <blockquote>
  <p>Property 'users' does not exist on type '{}'.ts(2339)</p>
  </blockquote>
  <p>The <code>RootState</code> type inferred is:</p>
  <pre><code>type RootState = {
      users: UsersSliceState;
  }
  </code></pre>
  <p>How should I make this type correctly? If I import the <code>RootState</code> type and type cast the return value of <code>getState()</code>, will it cause circular references?</p>
  <p>package versions:</p>
  <pre class="lang-json prettyprint-override"><code>&quot;@reduxjs/toolkit&quot;: &quot;^1.5.0&quot;,
  &quot;typescript&quot;: &quot;^4.1.2&quot;
  </code></pre>