import { Action } from 'redux' ; import { ChartMonitorAction , TOGGLE_VISIBILITY } from './actions' ; import { ChartMonitorProps } from './ChartMonitor' ; function toggleVisibility < S , A extends Action < unknown > > ( props , state = props . defaultIsVisible , action ) { if ( action . type === TOGGLE_VISIBILITY ) { return ! state ; } if ( props . defaultIsVisible !== undefined ) { return props . defaultIsVisible ; } return true ; } export interface ChartMonitorState { isVisible ? : boolean ; } export default function reducer < S , A extends Action < unknown > > ( props , state = { } , action ) { return { isVisible : toggleVisibility ( props , state . isVisible , action ) , } ; }