From eb9ba09e34b5794fefd351a0c8cf35aefba76458 Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Fri, 26 Nov 2021 15:09:44 -0500 Subject: [PATCH 1/3] Re-add explicit overload for a plain action --- src/types.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/types.ts b/src/types.ts index 3bd3368..7978253 100644 --- a/src/types.ts +++ b/src/types.ts @@ -11,22 +11,26 @@ import { Action, AnyAction, Middleware, Dispatch } from 'redux' * thunks (if specified when setting up the Thunk middleware) * @template BasicAction The (non-thunk) actions that can be dispatched. */ -export interface ThunkDispatch - extends Dispatch { - // When the thunk middleware is added, `store.dispatch` now has three overloads: - - // 1) The base overload, which accepts a standard action object, and returns that action object +export interface ThunkDispatch< + State, + ExtraThunkArg, + BasicAction extends Action +> { + // When the thunk middleware is added, `store.dispatch` now has three overloads (NOTE: the order here matters for correct behavior and is very fragile - do not reorder these!): - // 2) The specific thunk function overload + // 1) The specific thunk function overload /** Accepts a thunk function, runs it, and returns whatever the thunk itself returns */ ( thunkAction: ThunkAction ): ReturnType - // 3) - /** A union of the other two overloads. This overload exists to work around a problem - * with TS inference ( see https://github.com/microsoft/TypeScript/issues/14107 ) - */ + // 2) The base overload. + /** Accepts a standard action object, and returns that action object */ + (action: Action): Action + + // 3) A union of the other two overloads. This overload exists to work around a problem + // with TS inference ( see https://github.com/microsoft/TypeScript/issues/14107 ) + /** A union of the other two overloads for TS inference purposes */ ( action: Action | ThunkAction ): Action | ReturnType From ba38cc9c972c01c4596216bbf526c836c7e9af46 Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Fri, 26 Nov 2021 15:09:54 -0500 Subject: [PATCH 2/3] README cleanup --- README.md | 3 +-- package-lock.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1d8b6b2..64951e9 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ If you use Redux Thunk 2.x in a CommonJS environment, ``` Additionally, since 2.x, we also support a -[UMD build](https://unpkg.com/redux-thunk/dist/redux-thunk.min.js): +[UMD build](https://unpkg.com/redux-thunk/dist/redux-thunk.min.js) for use as a global script tag: ```js const ReduxThunk = window.ReduxThunk @@ -76,7 +76,6 @@ import { createStore, applyMiddleware } from 'redux' import thunk from 'redux-thunk' import rootReducer from './reducers/index' -// Note: this API requires redux@>=3.1.0 const store = createStore(rootReducer, applyMiddleware(thunk)) ``` diff --git a/package-lock.json b/package-lock.json index 3b82777..1d59912 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "redux-thunk", - "version": "2.3.0", + "version": "2.4.0", "license": "MIT", "devDependencies": { "@babel/cli": "^7.15.7", From 931b5bb25389c94818709cb33773494ceb24a9cd Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Fri, 26 Nov 2021 15:14:42 -0500 Subject: [PATCH 3/3] Add TS 4.5 to the matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e4fa93..9fe8039 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,7 @@ jobs: strategy: fail-fast: false matrix: - ts: ['3.9', '4.0', '4.1', '4.2', '4.3', '4.4', 'next'] + ts: ['3.9', '4.0', '4.1', '4.2', '4.3', '4.4', '4.5', 'next'] steps: - name: Checkout code