8
8
Observer ,
9
9
ExtendState
10
10
} from './types/store'
11
- import { Action } from './types/actions'
11
+ import { ReduxAction } from './types/actions'
12
12
import { Reducer } from './types/reducers'
13
13
import ActionTypes from './utils/actionTypes'
14
14
import isPlainObject from './utils/isPlainObject'
@@ -40,7 +40,7 @@ import isPlainObject from './utils/isPlainObject'
40
40
*/
41
41
export default function createStore <
42
42
S ,
43
- A extends Action ,
43
+ A extends ReduxAction ,
44
44
Ext = { } ,
45
45
StateExt = never
46
46
> (
@@ -49,7 +49,7 @@ export default function createStore<
49
49
) : Store < ExtendState < S , StateExt > , A , StateExt , Ext > & Ext
50
50
export default function createStore <
51
51
S ,
52
- A extends Action ,
52
+ A extends ReduxAction ,
53
53
Ext = { } ,
54
54
StateExt = never
55
55
> (
@@ -59,7 +59,7 @@ export default function createStore<
59
59
) : Store < ExtendState < S , StateExt > , A , StateExt , Ext > & Ext
60
60
export default function createStore <
61
61
S ,
62
- A extends Action ,
62
+ A extends ReduxAction ,
63
63
Ext = { } ,
64
64
StateExt = never
65
65
> (
@@ -221,7 +221,7 @@ export default function createStore<
221
221
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
222
222
* return something else (for example, a Promise you can await).
223
223
*/
224
- function dispatch ( action : A ) {
224
+ function dispatch ( action : A | ReduxAction ) {
225
225
if ( ! isPlainObject ( action ) ) {
226
226
throw new Error (
227
227
'Actions must be plain objects. ' +
@@ -242,7 +242,7 @@ export default function createStore<
242
242
243
243
try {
244
244
isDispatching = true
245
- currentState = currentReducer ( currentState , action )
245
+ currentState = currentReducer ( currentState , action as A )
246
246
} finally {
247
247
isDispatching = false
248
248
}
@@ -283,7 +283,7 @@ export default function createStore<
283
283
// Any reducers that existed in both the new and old rootReducer
284
284
// will receive the previous state. This effectively populates
285
285
// the new state tree with any relevant data from the old one.
286
- dispatch ( { type : ActionTypes . REPLACE } as A )
286
+ dispatch ( { type : ActionTypes . REPLACE } )
287
287
// change the type of the store by casting it to the new store
288
288
return ( store as unknown ) as Store <
289
289
ExtendState < NewState , StateExt > ,
@@ -337,7 +337,7 @@ export default function createStore<
337
337
// When a store is created, an "INIT" action is dispatched so that every
338
338
// reducer returns their initial state. This effectively populates
339
339
// the initial state tree.
340
- dispatch ( { type : ActionTypes . INIT } as A )
340
+ dispatch ( { type : ActionTypes . INIT } )
341
341
342
342
const store = ( {
343
343
dispatch : dispatch as Dispatch < A > ,
0 commit comments