Skip to content

Commit 8d8b188

Browse files
committed
Take another tack
1 parent 2634581 commit 8d8b188

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/typescript/reducers.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ interface AddTodoAction extends Action {
1111
}
1212

1313

14-
const todosReducer: Reducer<TodosState> = (state: TodosState,
15-
action: Action): TodosState => {
16-
switch (action.type) {
17-
case 'ADD_TODO':
18-
return [...state, (<AddTodoAction>action).text]
19-
default:
20-
return state
14+
const todosReducer: Reducer<TodosState, AddTodoAction> =
15+
(state, action) => {
16+
switch (action.type) {
17+
case 'ADD_TODO':
18+
return [...state, action.text]
19+
default:
20+
return state
21+
}
2122
}
22-
}
2323

2424
const todosState: TodosState = todosReducer([], {
2525
type: 'ADD_TODO',
@@ -48,7 +48,7 @@ type RootState = {
4848
}
4949

5050

51-
const rootReducer: Reducer<RootState> = combineReducers({
51+
const rootReducer = combineReducers<RootState, Action | AddTodoAction>({
5252
todos: todosReducer,
5353
counter: counterReducer,
5454
})

0 commit comments

Comments
 (0)