import { Reducer } from 'redux' ; import { CounterAction , CounterActionType as Type } from 'actions' ; export type CounterState = { count : number ; } ; export const initialState = { count : 0 } ; export const counterReducer = ( state = initialState , action ) : CounterState => { switch ( action . type ) { case Type . ADD : return { ... state , count : state . count + ( action . amount || 0 ) , } ; case Type . DECREMENT : return { ... state , count : state . count - 1 , } ; case Type . INCREMENT : return { ... state , count : state . count + 1 , } ; default : { const _ = action . type ; return state ; } } } ;