Skip to content

Commit 6b76c98

Browse files
committed
fix replaceReducer type
1 parent 9c9a4d2 commit 6b76c98

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

index.d.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ export interface Store<S = any, A extends Action = AnyAction> {
326326
*
327327
* @param nextReducer The reducer for the store to use instead.
328328
*/
329-
replaceReducer(nextReducer: Reducer<S, A>): void
329+
replaceReducer<NewState = S, NewActions extends A = A>(
330+
nextReducer: Reducer<NewState, NewActions>
331+
): Store<NewState, NewActions>
330332

331333
/**
332334
* Interoperability point for observable/reactive libraries.
@@ -667,3 +669,9 @@ export function compose<R>(
667669
): (...args: any[]) => R
668670

669671
export function compose<R>(...funcs: Function[]): (...args: any[]) => R
672+
673+
export const __DO_NOT_USE__ActionTypes: {
674+
INIT: string
675+
REPLACE: string
676+
PROBE_UNKNOWN_ACTION: () => string
677+
}

src/createStore.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export default function createStore(reducer, preloadedState, enhancer) {
238238
// will receive the previous state. This effectively populates
239239
// the new state tree with any relevant data from the old one.
240240
dispatch({ type: ActionTypes.REPLACE })
241+
return store
241242
}
242243

243244
/**
@@ -284,11 +285,12 @@ export default function createStore(reducer, preloadedState, enhancer) {
284285
// the initial state tree.
285286
dispatch({ type: ActionTypes.INIT })
286287

287-
return {
288+
const store = {
288289
dispatch,
289290
subscribe,
290291
getState,
291292
replaceReducer,
292293
[$$observable]: observable
293294
}
295+
return store
294296
}

0 commit comments

Comments
 (0)