Skip to content

Commit 5631c2d

Browse files
authored
Merge pull request #327 from reduxjs/feature/return-action-resolution
2 parents ce76464 + 931b5bb commit 5631c2d

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
ts: ['3.9', '4.0', '4.1', '4.2', '4.3', '4.4', 'next']
44+
ts: ['3.9', '4.0', '4.1', '4.2', '4.3', '4.4', '4.5', 'next']
4545

4646
steps:
4747
- name: Checkout code

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ If you use Redux Thunk 2.x in a CommonJS environment,
6060
```
6161

6262
Additionally, since 2.x, we also support a
63-
[UMD build](https://unpkg.com/redux-thunk/dist/redux-thunk.min.js):
63+
[UMD build](https://unpkg.com/redux-thunk/dist/redux-thunk.min.js) for use as a global script tag:
6464

6565
```js
6666
const ReduxThunk = window.ReduxThunk
@@ -76,7 +76,6 @@ import { createStore, applyMiddleware } from 'redux'
7676
import thunk from 'redux-thunk'
7777
import rootReducer from './reducers/index'
7878

79-
// Note: this API requires redux@>=3.1.0
8079
const store = createStore(rootReducer, applyMiddleware(thunk))
8180
```
8281

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/types.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,26 @@ import { Action, AnyAction, Middleware, Dispatch } from 'redux'
1111
* thunks (if specified when setting up the Thunk middleware)
1212
* @template BasicAction The (non-thunk) actions that can be dispatched.
1313
*/
14-
export interface ThunkDispatch<State, ExtraThunkArg, BasicAction extends Action>
15-
extends Dispatch<BasicAction> {
16-
// When the thunk middleware is added, `store.dispatch` now has three overloads:
17-
18-
// 1) The base overload, which accepts a standard action object, and returns that action object
14+
export interface ThunkDispatch<
15+
State,
16+
ExtraThunkArg,
17+
BasicAction extends Action
18+
> {
19+
// 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!):
1920

20-
// 2) The specific thunk function overload
21+
// 1) The specific thunk function overload
2122
/** Accepts a thunk function, runs it, and returns whatever the thunk itself returns */
2223
<ReturnType>(
2324
thunkAction: ThunkAction<ReturnType, State, ExtraThunkArg, BasicAction>
2425
): ReturnType
2526

26-
// 3)
27-
/** A union of the other two overloads. This overload exists to work around a problem
28-
* with TS inference ( see https://github.com/microsoft/TypeScript/issues/14107 )
29-
*/
27+
// 2) The base overload.
28+
/** Accepts a standard action object, and returns that action object */
29+
<Action extends BasicAction>(action: Action): Action
30+
31+
// 3) A union of the other two overloads. This overload exists to work around a problem
32+
// with TS inference ( see https://github.com/microsoft/TypeScript/issues/14107 )
33+
/** A union of the other two overloads for TS inference purposes */
3034
<ReturnType, Action extends BasicAction>(
3135
action: Action | ThunkAction<ReturnType, State, ExtraThunkArg, BasicAction>
3236
): Action | ReturnType

0 commit comments

Comments
 (0)