From e19559585d0e14583b6da0659246285c04ba002f Mon Sep 17 00:00:00 2001 From: Philipp Keck Date: Sat, 6 Jul 2019 17:06:00 +0200 Subject: [PATCH 1/2] #248 Add union overload to ThunkDispatch See discussion in #248 and https://github.com/microsoft/TypeScript/issues/14107. Without this explicit overload, TypeScript is unable to figure out that the function can be called with an argument of type `T|ThunkAction<...>`. --- index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.d.ts b/index.d.ts index bac521a..02ecefc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -26,6 +26,8 @@ export interface ThunkDispatch< thunkAction: ThunkAction ): TReturnType; (action: A): A; + // This overload is the union of the two above (see TS issue #14107). + (action: T | ThunkAction): T | R; } /** From fbbc99658d33a28b2e24c69df0fcc960b21e8cca Mon Sep 17 00:00:00 2001 From: Philipp Keck Date: Sat, 6 Jul 2019 22:44:42 +0200 Subject: [PATCH 2/2] Merge ThunkDispatch union overload with renamed type parameters Co-Authored-By: Tim Dorr --- index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 02ecefc..3c69133 100644 --- a/index.d.ts +++ b/index.d.ts @@ -27,7 +27,11 @@ export interface ThunkDispatch< ): TReturnType; (action: A): A; // This overload is the union of the two above (see TS issue #14107). - (action: T | ThunkAction): T | R; + ( + action: + | TAction + | ThunkAction + ): TAction | TReturnType; } /**