diff --git a/src/createStore.ts b/src/createStore.ts index 301190f821..4c333868c3 100644 --- a/src/createStore.ts +++ b/src/createStore.ts @@ -68,6 +68,14 @@ export default function createStore< preloadedState?: PreloadedState | StoreEnhancer, enhancer?: StoreEnhancer ): Store, A, StateExt, Ext> & Ext { + if (typeof reducer !== 'function') { + throw new Error( + `Expected the root reducer to be a function. Instead, received: '${kindOf( + reducer + )}'` + ) + } + if ( (typeof preloadedState === 'function' && typeof enhancer === 'function') || (typeof enhancer === 'function' && typeof arguments[3] === 'function') @@ -99,14 +107,6 @@ export default function createStore< ) as Store, A, StateExt, Ext> & Ext } - if (typeof reducer !== 'function') { - throw new Error( - `Expected the root reducer to be a function. Instead, received: '${kindOf( - reducer - )}'` - ) - } - let currentReducer = reducer let currentState = preloadedState as S let currentListeners: (() => void)[] | null = []