@@ -50,7 +50,7 @@ export default function createStore<S, A extends Action, Ext, StateExt>(
50
50
reducer : Reducer < S , A > ,
51
51
preloadedState ?: PreloadedState < S > | StoreEnhancer < Ext , StateExt > ,
52
52
enhancer ?: StoreEnhancer < Ext >
53
- ) {
53
+ ) : Store < S & StateExt , A > & Ext {
54
54
if (
55
55
( typeof preloadedState === 'function' && typeof enhancer === 'function' ) ||
56
56
( typeof enhancer === 'function' && typeof arguments [ 3 ] === 'function' )
@@ -72,7 +72,9 @@ export default function createStore<S, A extends Action, Ext, StateExt>(
72
72
throw new Error ( 'Expected the enhancer to be a function.' )
73
73
}
74
74
75
- return enhancer ( createStore ) ( reducer , preloadedState as PreloadedState < S > )
75
+ return enhancer ( createStore ) ( reducer , preloadedState as PreloadedState <
76
+ S
77
+ > ) as Store < S & StateExt , A > & Ext
76
78
}
77
79
78
80
if ( typeof reducer !== 'function' ) {
@@ -315,12 +317,12 @@ export default function createStore<S, A extends Action, Ext, StateExt>(
315
317
// the initial state tree.
316
318
dispatch ( { type : ActionTypes . INIT } as A )
317
319
318
- const store : Store < S , A > = ( {
320
+ const store : Store < S & StateExt , A > & Ext = ( {
319
321
dispatch : dispatch as Dispatch < A > ,
320
322
subscribe,
321
323
getState,
322
324
replaceReducer,
323
325
[ $$observable ] : observable
324
- } as unknown ) as Store < S , A >
326
+ } as unknown ) as Store < S & StateExt , A > & Ext
325
327
return store
326
328
}
0 commit comments