title: Typing Redux toolkit's store in TypeScript
body: <p>I'm trying to get started using Redux in React + TypeScript so I am following the Redux Toolkit's tutorials and try implementing it in a sample app.</p>
  
  <p>I am having a lot of difficulty with typings concerning the store and the <code>mappStateToProps</code> function parameters.</p>
  
  <p>I configured the store with a slice as follows:</p>
  
  <pre><code>import { configureStore } from '@reduxjs/toolkit'
  
  import linksReducer from '../features/links/linksSlice'
  
  const store = configureStore({
    reducer: {
      links: linksReducer,
    },
  })
  
  export default store
  export type AppStore = typeof store
  </code></pre>
  
  <p>And I connected a component like so:</p>
  
  <pre><code>import React from 'react'
  import { connect, ConnectedProps } from 'react-redux'
  
  import { AppStore } from '../../features/appStore'
  import { deleteLink } from '../../features/links/linksSlice'
  
  import LinkCard from './LinkCard'
  import Link from '../../models/Link'
  import EmptyList from './EmptyList'
  
  const mapStateToProps = (state: any) =&gt; ({
    links: state.links,
  })
  const mapDispatchToProps = { deleteLink }
  const connector = connect(mapStateToProps, mapDispatchToProps)
  
  const LinksGrid = (props: ConnectedProps&lt;typeof connector&gt;) =&gt; {
    //  ...
  }
  
  export default connector(LinksGrid)
  </code></pre>
  
  <p>As you can see, I used the <code>any</code> type for the first argument of the <code>mapStateToProps</code> function because I can't find out how I am supposed to type it. Using <code>any</code>, I have no problem running the application so I assume I only have a typing problem.</p>
  
  <p>The official documentation of RTK gives only an example of using <code>combineReducers</code> instead of <code>configureStore</code>, and it uses TS's <code>ReturnType&lt;T&gt;</code> which can only work on function but of course the <code>store</code> variable is not a function so it doesn't work.<br>
  I have also read the Redux and React Redux documentation but I still can't figure what to do.</p>
  
  <p>I am sure this is actually simple but here I am... Can anyone help me get that typing working?</p>
  
  <p>Thanks :)</p>