From 8551ba82711233e5f12eec2da7044a1c0602cf51 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Tue, 14 Jul 2020 10:34:26 -0400 Subject: [PATCH] Tighten applyMiddleware types (#3766) --- src/applyMiddleware.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/applyMiddleware.ts b/src/applyMiddleware.ts index f735843252..b0275f64f5 100644 --- a/src/applyMiddleware.ts +++ b/src/applyMiddleware.ts @@ -1,7 +1,12 @@ import compose from './compose' import { Middleware, MiddlewareAPI } from './types/middleware' import { AnyAction } from './types/actions' -import { StoreEnhancer, StoreCreator, Dispatch } from './types/store' +import { + StoreEnhancer, + Dispatch, + PreloadedState, + StoreEnhancerStoreCreator +} from './types/store' import { Reducer } from './types/reducers' /** @@ -55,11 +60,11 @@ export default function applyMiddleware( export default function applyMiddleware( ...middlewares: Middleware[] ): StoreEnhancer { - return (createStore: StoreCreator) => ( + return (createStore: StoreEnhancerStoreCreator) => ( reducer: Reducer, - ...args: any[] + preloadedState?: PreloadedState ) => { - const store = createStore(reducer, ...args) + const store = createStore(reducer, preloadedState) let dispatch: Dispatch = () => { throw new Error( 'Dispatching while constructing your middleware is not allowed. ' +