export const CounterActionType = { ADD : 'ADD' , DECREMENT : 'DECREMENT' , INCREMENT : 'INCREMENT' , } as const ; type ValueOf < T > = T [ keyof T ] ; export type CounterAction = { type : ValueOf < typeof CounterActionType > ; amount ? : number ; } ; export const add = ( amount ) : CounterAction => ( { type : CounterActionType . ADD , amount , } ) ; export const decrement = ( ) : CounterAction => ( { type : CounterActionType . DECREMENT , } ) ; export const increment = ( ) : CounterAction => ( { type : CounterActionType . INCREMENT , } ) ;