redux-thunk.d.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. // https://github.com/reduxjs/redux-thunk/issues/333
  2. import 'redux';
  3. declare module 'redux' {
  4. // eslint-disable-next-line jsdoc/require-returns
  5. /**
  6. * Overload for bindActionCreators redux function, returns expects responses
  7. * from thunk actions
  8. */
  9. function bindActionCreators<ActionCreators extends ActionCreatorsMapObject<any>>(
  10. actionCreators: ActionCreators,
  11. dispatch: Dispatch,
  12. ): {
  13. [ActionCreatorName in keyof ActionCreators]: ReturnType<
  14. ActionCreators[ActionCreatorName]
  15. > extends ThunkAction<any, any, any, any>
  16. ? (
  17. ...args: Parameters<ActionCreators[ActionCreatorName]>
  18. ) => ReturnType<ReturnType<ActionCreators[ActionCreatorName]>>
  19. : ActionCreators[ActionCreatorName];
  20. };
  21. /*
  22. * Overload to add thunk support to Redux's dispatch() function.
  23. * Useful for react-redux or any other library which could use this type.
  24. */
  25. export interface Dispatch<A extends Action = AnyAction> {
  26. <ReturnType = any, State = any, ExtraThunkArg = any>(
  27. thunkAction: ThunkAction<ReturnType, State, ExtraThunkArg, A>,
  28. ): ReturnType;
  29. }
  30. }