(state = 0, action)
| 17 | type State = number |
| 18 | |
| 19 | const reducer: Reducer<State> = (state = 0, action) => { |
| 20 | if (action.type === class="st">'INCREMENT') { |
| 21 | const { count = 1 } = action |
| 22 | if (typeof count === class="st">'number') { |
| 23 | return state + count |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | if (action.type === class="st">'DECREMENT') { |
| 28 | const { count = 1 } = action |
| 29 | if (typeof count === class="st">'number') { |
| 30 | return state + count |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | return state |
| 35 | } |
| 36 | |
| 37 | class="cm">// Reducer function accepts any object with `type` prop as action. |
| 38 | class="cm">// Any extra props are allowed too. |
no test coverage detected