Skip to content

Commit 464b61d

Browse files
#248 Add union overload to ThunkDispatch (#255)
* #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]>
1 parent 04f9437 commit 464b61d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ export interface ThunkDispatch<
2626
thunkAction: ThunkAction<TReturnType, TState, TExtraThunkArg, TBasicAction>
2727
): TReturnType;
2828
<A extends TBasicAction>(action: A): A;
29+
// This overload is the union of the two above (see TS issue #14107).
30+
<TReturnType, TAction extends TBasicAction>(
31+
action:
32+
| TAction
33+
| ThunkAction<TReturnType, TState, TExtraThunkArg, TBasicAction>
34+
): TAction | TReturnType;
2935
}
3036

3137
/**

0 commit comments

Comments
 (0)