Skip to content

Commit

Permalink
#248 Add union overload to ThunkDispatch (#255)
Browse files Browse the repository at this point in the history
* #248 Add union overload to ThunkDispatch

See discussion in #248 and microsoft/TypeScript#14107. Without this explicit overload, TypeScript is unable to figure out that the function can be called with an argument of type `T|ThunkAction<...>`.

* Merge ThunkDispatch union overload with renamed type parameters

Co-Authored-By: Tim Dorr <[email protected]>
  • Loading branch information
MiyamotoSatoshi and timdorr committed Jul 6, 2019
1 parent 04f9437 commit 464b61d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export interface ThunkDispatch<
thunkAction: ThunkAction<TReturnType, TState, TExtraThunkArg, TBasicAction>
): TReturnType;
<A extends TBasicAction>(action: A): A;
// This overload is the union of the two above (see TS issue #14107).
<TReturnType, TAction extends TBasicAction>(
action:
| TAction
| ThunkAction<TReturnType, TState, TExtraThunkArg, TBasicAction>
): TAction | TReturnType;
}

/**
Expand Down

0 comments on commit 464b61d

Please sign in to comment.