I'm getting an error:
Parameter 'getDefaultMiddleware' implicitly has an 'any' type.
My store code looks like this:
import { configureStore } from '@reduxjs/toolkit';
import uiStateReducer from './ui_state';
import logger from 'redux-logger';
const rootReducer = {
uiState: uiStateReducer,
middleware: (getDefaultMiddleware) => {
return getDefaultMiddleware.concat(logger)
}
};
const store = configureStore({ reducer: rootReducer });
I've checked the Redux-Toolkit Github issues page for anyone who's having this issue (couldn't find anything) and all the code snippets of other issues showing the (getDefaultMiddleware) => { function do not explicitly type the getDefaultMiddleware. Can someone point me to how getDefaultMiddleware can be inferred?
Redux middleware is added to the store when it is created, not as a reducer function. It seems that Typescript is reading this as a reducer function and letting you know the "state" argument isn't explicitly typed.
See middleware
If using the
getDefaultMiddlewarefunction then the types are inferred more easily.If Typescript users are just adding their own middleware then they must return a
Tuple.