Typescript error when using object as parameter for makeStore function
balibou opened this issue · 0 comments
balibou commented
Describe the bug
When I set an object parameter with preloadedState and clientApi, I get Type 'NextPageContext<any>' has no properties in common with type '{ preloadedState?: any; clientApi?: any; }'
To Reproduce
CodeSandbox template https://codesandbox.io/s/next-redux-wrapper-demo-7n2t5 doesn't use rtk, so I'm gonna drop an as clear as possible code here:
export const makeStore: MakeStore<any> = ({
preloadedState,
clientApi,
}: {
preloadedState?: any;
clientApi?: any;
} = {}) =>
configureStore({
reducer: anyReducer,
preloadedState,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
thunk: {
extraArgument: { clientApi },
},
}),
});
Expected behaviour
I want the same behaviour as the following code:
export const makeStore: MakeStore<any> = (
preloadedState?: any,
clientApi?: any,
) =>
configureStore({
reducer: anyReducer,
preloadedState,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
thunk: {
extraArgument: { clientApi },
},
}),
});
Desktop:
- MacOS Ventura 13.4
- Node 18.15.0 / next-redux-wrapper 8.1.0 / @reduxjs/toolkit 1.9.7