From d4909d3e10f254339799a895ece47ee6b523491d Mon Sep 17 00:00:00 2001 From: Mark Erikson Date: Sun, 3 Dec 2023 23:39:58 -0500 Subject: [PATCH] Kill the bindActionCreators overload for now --- extend-redux.d.ts | 32 ++++++++++--------- .../typescript_extended/extended-redux.ts | 28 ++++++++-------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/extend-redux.d.ts b/extend-redux.d.ts index e413ecb..85aa60f 100644 --- a/extend-redux.d.ts +++ b/extend-redux.d.ts @@ -1,3 +1,4 @@ +import type { Action, UnknownAction, ActionCreatorsMapObject } from 'redux' import type { ThunkAction } from './src/index' /** @@ -15,26 +16,27 @@ declare module 'redux' { * Overload for bindActionCreators redux function, returns expects responses * from thunk actions */ - function bindActionCreators< - ActionCreators extends ActionCreatorsMapObject - >( - actionCreators: ActionCreators, - dispatch: Dispatch - ): { - [ActionCreatorName in keyof ActionCreators]: ReturnType< - ActionCreators[ActionCreatorName] - > extends ThunkAction - ? ( - ...args: Parameters - ) => ReturnType> - : ActionCreators[ActionCreatorName] - } + // TODO Fix this post-3.0.1 + // export function bindActionCreators< + // ActionCreators extends ActionCreatorsMapObject + // >( + // actionCreators: ActionCreators, + // dispatch: Dispatch + // ): { + // [ActionCreatorName in keyof ActionCreators]: ReturnType< + // ActionCreators[ActionCreatorName] + // > extends ThunkAction + // ? ( + // ...args: Parameters + // ) => ReturnType> + // : ActionCreators[ActionCreatorName] + // } /* * Overload to add thunk support to Redux's dispatch() function. * Useful for react-redux or any other library which could use this type. */ - export interface Dispatch { + export interface Dispatch { ( thunkAction: ThunkAction ): ReturnType diff --git a/typescript_test/typescript_extended/extended-redux.ts b/typescript_test/typescript_extended/extended-redux.ts index 74b055a..9a0106a 100644 --- a/typescript_test/typescript_extended/extended-redux.ts +++ b/typescript_test/typescript_extended/extended-redux.ts @@ -72,17 +72,17 @@ interface ActionDispatchs { // also ensure standard action creators still work as expected. // Unlike the main file, this declaration should compile okay because we've imported // the global module override -const actions: ActionDispatchs = bindActionCreators( - { - anotherThunkAction, - promiseThunkAction, - standardAction - }, - store.dispatch -) - -const untypedStore = createStore(fakeReducer, applyMiddleware(thunk)) - -// Similarly, both of these declarations should pass okay as well -untypedStore.dispatch(anotherThunkAction()) -untypedStore.dispatch(promiseThunkAction()).then(() => Promise.resolve()) +// const actions: ActionDispatchs = bindActionCreators( +// { +// anotherThunkAction, +// promiseThunkAction, +// standardAction +// }, +// store.dispatch +// ) + +// const untypedStore = createStore(fakeReducer, applyMiddleware(thunk)) + +// // Similarly, both of these declarations should pass okay as well +// untypedStore.dispatch(anotherThunkAction()) +// untypedStore.dispatch(promiseThunkAction()).then(() => Promise.resolve())