diff --git a/test/typescript/dispatch.ts b/test/typescript/dispatch.ts index 6f051421f2..c5361dee36 100644 --- a/test/typescript/dispatch.ts +++ b/test/typescript/dispatch.ts @@ -7,8 +7,8 @@ const dispatchResult: Action = dispatch({type: 'TYPE'}); // thunk declare module "../../" { - export interface Dispatch { - (asyncAction: (dispatch: Dispatch, getState: () => S) => R): R; + export interface Dispatch { + (asyncAction: (dispatch: Dispatch, getState: () => any) => R): R; } } diff --git a/test/typescript/middleware.ts b/test/typescript/middleware.ts index b3aaf9ae9b..f25fa2db30 100644 --- a/test/typescript/middleware.ts +++ b/test/typescript/middleware.ts @@ -4,17 +4,17 @@ import { } from "../../" declare module "../../" { - export interface Dispatch { - (asyncAction: (dispatch: Dispatch, getState: () => S) => R): R; + export interface Dispatch { + (asyncAction: (dispatch: Dispatch, getState: () => any) => R): R; } } -type Thunk = (dispatch: Dispatch, getState?: () => S) => O; +type Thunk = (dispatch: Dispatch, getState?: () => S) => O; const thunkMiddleware: Middleware = - ({dispatch, getState}: MiddlewareAPI) => - (next: Dispatch) => - (action: A | Thunk): B|Action => + ({dispatch, getState}: MiddlewareAPI) => + (next: Dispatch) => + (action: A | Thunk): B|Action => typeof action === 'function' ? (>action)(dispatch, getState) : next(action) @@ -22,7 +22,7 @@ const thunkMiddleware: Middleware = const loggerMiddleware: Middleware = ({getState}: MiddlewareAPI) => - (next: Dispatch) => + (next: Dispatch) => (action: any): any => { console.log('will dispatch', action) @@ -51,7 +51,7 @@ const storeWithThunkMiddleware = createStore( ); storeWithThunkMiddleware.dispatch( - (dispatch: Dispatch, getState: () => State) => { + (dispatch: Dispatch, getState: () => State) => { const todos: string[] = getState().todos; dispatch({type: 'ADD_TODO'}) }