Skip to content

Commit d4909d3

Browse files
committed
Kill the bindActionCreators overload for now
1 parent ece6c25 commit d4909d3

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

extend-redux.d.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Action, UnknownAction, ActionCreatorsMapObject } from 'redux'
12
import type { ThunkAction } from './src/index'
23

34
/**
@@ -15,26 +16,27 @@ declare module 'redux' {
1516
* Overload for bindActionCreators redux function, returns expects responses
1617
* from thunk actions
1718
*/
18-
function bindActionCreators<
19-
ActionCreators extends ActionCreatorsMapObject<any>
20-
>(
21-
actionCreators: ActionCreators,
22-
dispatch: Dispatch
23-
): {
24-
[ActionCreatorName in keyof ActionCreators]: ReturnType<
25-
ActionCreators[ActionCreatorName]
26-
> extends ThunkAction<any, any, any, any>
27-
? (
28-
...args: Parameters<ActionCreators[ActionCreatorName]>
29-
) => ReturnType<ReturnType<ActionCreators[ActionCreatorName]>>
30-
: ActionCreators[ActionCreatorName]
31-
}
19+
// TODO Fix this post-3.0.1
20+
// export function bindActionCreators<
21+
// ActionCreators extends ActionCreatorsMapObject<any>
22+
// >(
23+
// actionCreators: ActionCreators,
24+
// dispatch: Dispatch
25+
// ): {
26+
// [ActionCreatorName in keyof ActionCreators]: ReturnType<
27+
// ActionCreators[ActionCreatorName]
28+
// > extends ThunkAction<any, any, any, any>
29+
// ? (
30+
// ...args: Parameters<ActionCreators[ActionCreatorName]>
31+
// ) => ReturnType<ReturnType<ActionCreators[ActionCreatorName]>>
32+
// : ActionCreators[ActionCreatorName]
33+
// }
3234

3335
/*
3436
* Overload to add thunk support to Redux's dispatch() function.
3537
* Useful for react-redux or any other library which could use this type.
3638
*/
37-
export interface Dispatch<A extends Action = AnyAction> {
39+
export interface Dispatch<A extends Action = UnknownAction> {
3840
<ReturnType = any, State = any, ExtraThunkArg = any>(
3941
thunkAction: ThunkAction<ReturnType, State, ExtraThunkArg, A>
4042
): ReturnType

typescript_test/typescript_extended/extended-redux.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ interface ActionDispatchs {
7272
// also ensure standard action creators still work as expected.
7373
// Unlike the main file, this declaration should compile okay because we've imported
7474
// the global module override
75-
const actions: ActionDispatchs = bindActionCreators(
76-
{
77-
anotherThunkAction,
78-
promiseThunkAction,
79-
standardAction
80-
},
81-
store.dispatch
82-
)
83-
84-
const untypedStore = createStore(fakeReducer, applyMiddleware(thunk))
85-
86-
// Similarly, both of these declarations should pass okay as well
87-
untypedStore.dispatch(anotherThunkAction())
88-
untypedStore.dispatch(promiseThunkAction()).then(() => Promise.resolve())
75+
// const actions: ActionDispatchs = bindActionCreators(
76+
// {
77+
// anotherThunkAction,
78+
// promiseThunkAction,
79+
// standardAction
80+
// },
81+
// store.dispatch
82+
// )
83+
84+
// const untypedStore = createStore(fakeReducer, applyMiddleware(thunk))
85+
86+
// // Similarly, both of these declarations should pass okay as well
87+
// untypedStore.dispatch(anotherThunkAction())
88+
// untypedStore.dispatch(promiseThunkAction()).then(() => Promise.resolve())

0 commit comments

Comments
 (0)