File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ import { combineReducers , createStore } from 'redux'
2+
3+ /**
4+ * verify that replaceReducer maintains strict typing if the new types change
5+ */
6+ const bar = ( state = { value : 'bar' } ) => state
7+ const baz = ( state = { value : 'baz' } ) => state
8+ const ACTION = {
9+ type : 'action'
10+ }
11+
12+ const originalCompositeReducer = combineReducers ( { bar } )
13+ const store = createStore ( originalCompositeReducer )
14+ store . dispatch ( ACTION )
15+
16+ const firstState = store . getState ( )
17+ firstState . bar . value
18+ // typings:expect-error
19+ firstState . baz . value
20+
21+ const nextStore = store . replaceReducer ( combineReducers ( { baz } ) ) // returns -> { baz: { value: 'baz' }}
22+
23+ const nextState = nextStore . getState ( )
24+ // typings:expect-error
25+ nextState . bar . value
26+ nextState . baz . value
You can’t perform that action at this time.
0 commit comments