import { Action , applyMiddleware , compose , createStore , Middleware , PreloadedState , ReducersMapObject , Store } from 'redux' ; import { createLogger } from 'redux-logger' ; import thunk from 'redux-thunk' ; import setupReducers from '../reducers' ; const anyWindow = window ; let standardMiddleware = [ thunk ] ; if ( __DEV__ ) { const reduxImmutableStateInvariant = require ( 'redux-immutable-state-invariant' ) . default ( ) ; const logger = createLogger ( { collapsed : true } ) ; standardMiddleware = [ ... standardMiddleware , reduxImmutableStateInvariant , logger ] ; } const composeEnhancers = ( typeof anyWindow !== 'undefined' && anyWindow [ '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__' ] ) || compose ; export default function configureStore < S , A extends Action , Ext , StateExt > ( initialState = { } as PreloadedState < S > , reducers , middleware ) { return createStore < S , A , Ext , StateExt > ( setupReducers < S , A > ( reducers ) , initialState , composeEnhancers ( applyMiddleware ( ... middleware , ... standardMiddleware ) ) ) ; }