Skip to content

Commit

Permalink
Tighten applyMiddleware types (#3766)
Browse files Browse the repository at this point in the history
  • Loading branch information
Methuselah96 authored Jul 14, 2020
1 parent f77a95a commit 8551ba8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/applyMiddleware.ts
Original file line number Diff line number Diff line change
@@ -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'

/**
Expand Down Expand Up @@ -55,11 +60,11 @@ export default function applyMiddleware<Ext, S = any>(
export default function applyMiddleware(
...middlewares: Middleware[]
): StoreEnhancer<any> {
return (createStore: StoreCreator) => <S, A extends AnyAction>(
return (createStore: StoreEnhancerStoreCreator) => <S, A extends AnyAction>(
reducer: Reducer<S, A>,
...args: any[]
preloadedState?: PreloadedState<S>
) => {
const store = createStore(reducer, ...args)
const store = createStore(reducer, preloadedState)
let dispatch: Dispatch = () => {
throw new Error(
'Dispatching while constructing your middleware is not allowed. ' +
Expand Down

0 comments on commit 8551ba8

Please sign in to comment.