0

Error on MakeStore saying Generic type 'MakeStore' requires 1 type argument(s) .ts(2314)

configureStore.ts is the following:

import {
  configureStore,
  EnhancedStore,
  getDefaultMiddleware,
} from '@reduxjs/toolkit';
import { MakeStore } from 'next-redux-wrapper';
import { Env } from '../constants';
import { rootReducer, RootState } from './reducers';
import logger from 'redux-logger';

const store = configureStore({
  reducer: rootReducer,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware()
      .concat(logger),
  devTools: Env.NODE_ENV === 'development',
});

export const makeStore: MakeStore = (_?: RootState): EnhancedStore => store;

Thanks in advance.

Abdul Mahamaliyev
  • 750
  • 1
  • 8
  • 20

1 Answers1

0

Remove the EnhancedStore type. You should never use that type directly, because you'll actually end up throwing away the real type information that is inferred from the call to configureStore() itself.

markerikson
  • 63,178
  • 10
  • 141
  • 157
  • thanks for the suggestion. turns out it was outdated way of configuring the store. rewrote it according to the answer [here:](https://stackoverflow.com/questions/70426965/how-to-use-next-redux-wrapper-with-next-js-redux-toolkit-and-typescript-p) – Abdul Mahamaliyev Jun 06 '22 at 04:12