@@ -42,7 +42,7 @@ function simple() {
42
42
// Combined reducer also accepts any action.
43
43
const combined = combineReducers ( { sub : reducer } )
44
44
45
- let cs = combined ( undefined , { type : 'init' } )
45
+ let cs : { sub : State } = combined ( undefined , { type : 'init' } )
46
46
cs = combined ( cs , { type : 'INCREMENT' , count : 10 } )
47
47
48
48
// Combined reducer's state is strictly checked.
@@ -110,18 +110,17 @@ function discriminated() {
110
110
// typings:expect-error
111
111
s = reducer ( s , { type : 'SOME_OTHER_TYPE' , someField : 'value' } )
112
112
113
- // Combined reducer accepts a union actions types accepted each reducer,
114
- // which can be very permissive for unknown third-party reducers.
115
- const combined = combineReducers ( {
116
- sub : reducer ,
117
- unknown : ( state => state ) as Reducer
118
- } )
113
+ // Combined reducer accepts any action by default which allows to include
114
+ // third-party reducers without the need to add their actions to the union.
115
+ const combined = combineReducers ( { sub : reducer } )
119
116
120
- let cs = combined ( undefined , { type : 'init' } )
121
- cs = combined ( cs , { type : 'SOME_OTHER_TYPE' , someField : 'value' } )
117
+ let cs : { sub : State } = combined ( undefined , { type : 'init' } )
118
+ cs = combined ( cs , { type : 'SOME_OTHER_TYPE' } )
122
119
123
120
// Combined reducer can be made to only accept known actions.
124
- const strictCombined = combineReducers ( { sub : reducer } )
121
+ const strictCombined = combineReducers < { sub : State } , MyAction > ( {
122
+ sub : reducer
123
+ } )
125
124
126
125
strictCombined ( cs , { type : 'INCREMENT' } )
127
126
// typings:expect-error
@@ -180,7 +179,7 @@ function typeGuards() {
180
179
181
180
const combined = combineReducers ( { sub : reducer } )
182
181
183
- let cs = combined ( undefined , { type : 'init' } )
182
+ let cs : { sub : State } = combined ( undefined , { type : 'init' } )
184
183
cs = combined ( cs , { type : 'INCREMENT' , count : 10 } )
185
184
}
186
185
0 commit comments