diff --git a/index.d.ts b/index.d.ts index 24cf875..d2e6458 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,18 +1,18 @@ -import {Middleware, Dispatch} from "redux"; +import { Action, Middleware, Dispatch as ReduxDispatch, Store as ReduxStore } from "redux"; - -export type ThunkAction = (dispatch: Dispatch, getState: () => S, - extraArgument: E) => R; - -declare module "redux" { - export interface Dispatch { +export interface Dispatch extends ReduxDispatch { (asyncAction: ThunkAction): R; - } } +export interface Store extends ReduxStore { + dispatch: Dispatch; +} + +export type ThunkAction = (dispatch: Dispatch, getState: () => S, + extraArgument: E) => R; declare const thunk: Middleware & { - withExtraArgument(extraArgument: any): Middleware; + withExtraArgument(extraArgument: any): Middleware; }; export default thunk; diff --git a/test/typescript.ts b/test/typescript.ts index 816bf47..a43e5e2 100644 --- a/test/typescript.ts +++ b/test/typescript.ts @@ -1,6 +1,5 @@ -import {Store, Middleware} from 'redux'; -import thunk, {ThunkAction} from '../index.d.ts'; - +import { Action, Dispatch as ReduxDispatch, Middleware } from 'redux'; +import thunk, { Dispatch, ThunkAction, Store } from '../index.d.ts'; declare const store: Store<{foo: string}>; @@ -31,3 +30,7 @@ const thunkAction: ThunkAction = const thunkActionDispatchOnly: ThunkAction = dispatch => { dispatch({type: 'FOO'}); }; + +export const otherMiddleware: Middleware = (store: Store) => (next: ReduxDispatch) => (action: Action) => { + next(action); +};