v2.4.0
版本发布时间: 2021-10-26 09:19:05
reduxjs/redux-thunk最新发布版本:v3.1.0(2023-12-04 21:57:13)
This very overdue release makes several major improvements to the TypeScript types, and converts the actual source to TypeScript. Sorry for the delay!
Changelog
TypeScript Improvements
This release fixes several outstanding issues that had been reported with the types. An extra overload has been added to let TS correctly understand some generically-typed values being passed to dispatch
, and the overloads have been reworked for additional compatibility.
There's also a new ThunkActionDispatch
type that can be used to represent how bindActionCreators
turns bound thunks into (arg) => thunkReturnValue
.
Additionally, all of the generic args have been giving meaningful names instead of one-letter abbreviations (S
-> State
, E
-> ExtraArgument
, etc), and we've added descriptive comments in the type definitions for clarity.
Optional Global Dispatch
Type Extension
Most Redux apps have the thunk middleware enabled, but the default Dispatch
and bindActionCreator
types only know about the standard behavior of a basic Redux store without any middleware. The thunk middleware types add to that type behavior, so that Dispatch
knows dispatching a thunk can actually return a value such as a Promise.
We generally recommend inferring the type of dispatch
and using that to create reusable types, including creating pre-typed hooks. However, some users may prefer to globally augment the Dispatch
type to always use the additional thunk behavior.
You can now import 'redux-thunk/extend-redux'
to globally augment the Dispatch
type as an opt-in change in behavior.
Codebase Converted to TypeScript
We've gone ahead and converted the actual source to TS. Since the source was only 15-ish lines to begin with, most of the "conversion" time was just trying to convince TS that assigning thunk.extraArgument = createThunkMiddleware
was a legal operation :)
We also updated the build tooling:
- Babel updates
- Rollup for the UMDs instead of Webpack
- Github Actions for CI instead of Travis
Finally, the README has been updated with newer instructions and usage information.
What's Changed
- Change misleading parameter name for overload of ThunkDispatch by @jmrog in https://github.com/reduxjs/redux-thunk/pull/216
- --save no longer needed by @JoeCortopassi in https://github.com/reduxjs/redux-thunk/pull/217
- Allow action to be typed with any by @laat in https://github.com/reduxjs/redux-thunk/pull/219
- Add overload for bindActionCreators by @RMHonor in https://github.com/reduxjs/redux-thunk/pull/224
- promote gender neutral docs by @beatfactor in https://github.com/reduxjs/redux-thunk/pull/234
- Clarify terminology by @jmm in https://github.com/reduxjs/redux-thunk/pull/237
- Provide more informative names for TypeScript type params by @agwells in https://github.com/reduxjs/redux-thunk/pull/243
- Add peer dependency on redux 4.0 by @hedgepigdaniel in https://github.com/reduxjs/redux-thunk/pull/251
- chore: remove 2015 preset and add env by @hozefaj in https://github.com/reduxjs/redux-thunk/pull/236
- #248 Add union overload to ThunkDispatch by @Philipp91 in https://github.com/reduxjs/redux-thunk/pull/255
- fix: extraThunkArgument types by @jedmao in https://github.com/reduxjs/redux-thunk/pull/260
- Upgrade dependencies by @jedmao in https://github.com/reduxjs/redux-thunk/pull/261
- Add Prettier by @jedmao in https://github.com/reduxjs/redux-thunk/pull/262
- fix: typo TExtraThunkARg -> TExtraThunkArg by @jedmao in https://github.com/reduxjs/redux-thunk/pull/263
- declare this package as having no side effects by @VincentBailly in https://github.com/reduxjs/redux-thunk/pull/267
- Reflect rename of Redux Starter Kit by @travigd in https://github.com/reduxjs/redux-thunk/pull/270
- Correct destructuring example by @telegraham in https://github.com/reduxjs/redux-thunk/pull/272
- Fix link by @mhienle in https://github.com/reduxjs/redux-thunk/pull/276
- feat(ts): add Dispatch overload to redux module by @iamandrewluca in https://github.com/reduxjs/redux-thunk/pull/278
- docs: fix link for
applyMiddleware
by @iamandrewluca in https://github.com/reduxjs/redux-thunk/pull/279 - Improved wording in README.md by @haricharanbole in https://github.com/reduxjs/redux-thunk/pull/293
- chore: add yarn add line by @RichardBray in https://github.com/reduxjs/redux-thunk/pull/305
- Use "sh" instead of "js" in install instructions by @EvanHahn in https://github.com/reduxjs/redux-thunk/pull/312
- Remove redundant
|
by @Philipp91 in https://github.com/reduxjs/redux-thunk/pull/317 - Use GitHub Actions by @nickmccurdy in https://github.com/reduxjs/redux-thunk/pull/318
- Update TS dev tooling and GH Actions workflow by @markerikson in https://github.com/reduxjs/redux-thunk/pull/320
- Move Redux module type extension into a separate imported file by @markerikson in https://github.com/reduxjs/redux-thunk/pull/321
- Add CodeSandbox CI by @markerikson in https://github.com/reduxjs/redux-thunk/pull/323
- Convert codebase to TS and update build tooling by @markerikson in https://github.com/reduxjs/redux-thunk/pull/322
- Remove Webpack config and try test build by @markerikson in https://github.com/reduxjs/redux-thunk/pull/324
New Contributors
- @jmrog made their first contribution in https://github.com/reduxjs/redux-thunk/pull/216
- @JoeCortopassi made their first contribution in https://github.com/reduxjs/redux-thunk/pull/217
- @laat made their first contribution in https://github.com/reduxjs/redux-thunk/pull/219
- @RMHonor made their first contribution in https://github.com/reduxjs/redux-thunk/pull/224
- @beatfactor made their first contribution in https://github.com/reduxjs/redux-thunk/pull/234
- @jmm made their first contribution in https://github.com/reduxjs/redux-thunk/pull/237
- @agwells made their first contribution in https://github.com/reduxjs/redux-thunk/pull/243
- @hedgepigdaniel made their first contribution in https://github.com/reduxjs/redux-thunk/pull/251
- @hozefaj made their first contribution in https://github.com/reduxjs/redux-thunk/pull/236
- @Philipp91 made their first contribution in https://github.com/reduxjs/redux-thunk/pull/255
- @jedmao made their first contribution in https://github.com/reduxjs/redux-thunk/pull/260
- @VincentBailly made their first contribution in https://github.com/reduxjs/redux-thunk/pull/267
- @travigd made their first contribution in https://github.com/reduxjs/redux-thunk/pull/270
- @telegraham made their first contribution in https://github.com/reduxjs/redux-thunk/pull/272
- @mhienle made their first contribution in https://github.com/reduxjs/redux-thunk/pull/276
- @iamandrewluca made their first contribution in https://github.com/reduxjs/redux-thunk/pull/278
- @haricharanbole made their first contribution in https://github.com/reduxjs/redux-thunk/pull/293
- @RichardBray made their first contribution in https://github.com/reduxjs/redux-thunk/pull/305
- @EvanHahn made their first contribution in https://github.com/reduxjs/redux-thunk/pull/312
- @nickmccurdy made their first contribution in https://github.com/reduxjs/redux-thunk/pull/318
- @markerikson made their first contribution in https://github.com/reduxjs/redux-thunk/pull/320
Full Changelog: https://github.com/reduxjs/redux-thunk/compare/v2.3.0...v2.4.0