Skip to content

Commit

Permalink
Fix typescript tests for new d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyt1 committed Oct 22, 2017
1 parent 1e9529b commit b9278d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions test/typescript/dispatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const dispatchResult: Action = dispatch({type: 'TYPE'});

// thunk
declare module "../../" {
export interface Dispatch<S> {
<R>(asyncAction: (dispatch: Dispatch<S>, getState: () => S) => R): R;
export interface Dispatch<D = Action> {
<R>(asyncAction: (dispatch: Dispatch<D>, getState: () => D) => R): R;
}
}

Expand Down
10 changes: 5 additions & 5 deletions test/typescript/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import {
} from "../../"

declare module "../../" {
export interface Dispatch<S> {
<R>(asyncAction: (dispatch: Dispatch<S>, getState: () => S) => R): R;
export interface Dispatch<D> {
<R,S>(asyncAction: (dispatch: Dispatch<D>, getState: () => S) => R): R;
}
}

type Thunk<S, O> = (dispatch: Dispatch<S>, getState?: () => S) => O;
type Thunk<S, O> = (dispatch: Dispatch<Action>, getState?: () => S) => O;

const thunkMiddleware: Middleware =
<S>({dispatch, getState}: MiddlewareAPI<S>) =>
(next: Dispatch<S>) =>
(next: Dispatch<Action>) =>
<A extends Action, B>(action: A | Thunk<S, B>): B|Action =>
typeof action === 'function' ?
(<Thunk<S, B>>action)(dispatch, getState) :
Expand Down Expand Up @@ -51,7 +51,7 @@ const storeWithThunkMiddleware = createStore(
);

storeWithThunkMiddleware.dispatch(
(dispatch: Dispatch<State>, getState: () => State) => {
(dispatch: Dispatch<Action>, getState: () => State) => {
const todos: string[] = getState().todos;
dispatch({type: 'ADD_TODO'})
}
Expand Down

0 comments on commit b9278d1

Please sign in to comment.