actions: improve type inference

It seems like there should be a better way to do this.
This commit is contained in:
David Lechner
2022-02-28 12:22:08 -06:00
parent 02d7672155
commit 97363b4327
+4 -3
View File
@@ -44,9 +44,10 @@ type Matchable<F extends ActionCreationFunction<A>, A extends AnyAction> = F &
* @param actionCreator The action creation function.
* @returns actionCreator with type property and match method added.
*/
export function createAction<F extends ActionCreationFunction<A>, A extends AnyAction>(
actionCreator: F,
): Matchable<F, A> {
export function createAction<
F extends ActionCreationFunction<A>,
A extends AnyAction = ReturnType<F>,
>(actionCreator: F): Matchable<F, A> {
// create a default action so we can get the type string.
const type = actionCreator().type;