// create-reducer.ts import { Action } from 'redux'; type Handlers> = { readonly [Type in Types]: (state: State, action: Actions) => State } // export const createReducer = >( // initialState: State, // handlers: Handlers, // ) => (state = initialState, action: Actions) => // handlers.hasOwnProperty(action.type) ? handlers[action.type as Types](state, action) : state; export const createReducer = ( initialState, handlers, ) => (state = initialState, action) => (handlers.hasOwnProperty(action.type) ? handlers[action.type](state, action) : state);