diff --git a/services/common/src/redux/rootState.ts b/services/common/src/redux/rootState.ts index eeb94a7cd6..929b0970f4 100644 --- a/services/common/src/redux/rootState.ts +++ b/services/common/src/redux/rootState.ts @@ -1,9 +1,10 @@ import { sharedReducer } from "@mds/common/redux/reducers/rootReducerShared"; -import { configureStore } from "@reduxjs/toolkit"; +import { configureStore, Dispatch } from "@reduxjs/toolkit"; import { loadingBarReducer } from "react-redux-loading-bar"; import type { TypedUseSelectorHook } from 'react-redux' import { useDispatch, useSelector, useStore } from 'react-redux' +import type { FormAction } from 'redux-form'; export const getStore = (preloadedState = {}) => configureStore({ @@ -17,10 +18,14 @@ export const getStore = (preloadedState = {}) => export const store = getStore(); -// Provide typed versions for global redux functions +/** + * Provide typed versions for global redux functions +**/ + type RootState = ReturnType; -export type AppDispatch = typeof store.dispatch; +// Infer the `RootState` and `AppDispatch` types from the store itself + make sure redux-form actions are captured as well. +export type AppDispatch = typeof store.dispatch & Dispatch; export type AppStore = typeof store; // Use throughout your app instead of plain `useDispatch` and `useSelector`