Skip to content

Commit 02bbfba

Browse files
committed
simplify GetCaseReducers
1 parent a9e3fa4 commit 02bbfba

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

packages/toolkit/src/createSlice.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -507,17 +507,8 @@ type CreatorCallback<
507507
) => Record<string, ReducerDefinition>
508508

509509
type GetCaseReducers<
510-
State,
511-
Name extends string,
512-
ReducerPath extends string,
513-
CreatorMap extends Record<string, RegisteredReducerType>,
514-
CR extends
515-
| SliceCaseReducers<State>
516-
| CreatorCallback<State, Name, ReducerPath, CreatorMap>,
517-
> =
518-
CR extends CreatorCallback<State, Name, ReducerPath, CreatorMap>
519-
? ReturnType<CR>
520-
: CR
510+
CR extends SliceCaseReducers<any> | CreatorCallback<any, any, any, any>,
511+
> = CR extends CreatorCallback<any, any, any, any> ? ReturnType<CR> : CR
521512

522513
/**
523514
* Options for `createSlice()`.
@@ -916,13 +907,7 @@ export function buildCreateSlice<
916907
Selectors,
917908
CreatorMap
918909
>,
919-
): Slice<
920-
State,
921-
GetCaseReducers<State, Name, ReducerPath, CreatorMap, CaseReducers>,
922-
Name,
923-
ReducerPath,
924-
Selectors
925-
> {
910+
): Slice<State, GetCaseReducers<CaseReducers>, Name, ReducerPath, Selectors> {
926911
const { name, reducerPath = name as unknown as ReducerPath } = options
927912
if (!name) {
928913
throw new Error('`name` is a required option for createSlice')
@@ -1119,7 +1104,7 @@ export function buildCreateSlice<
11191104
): Pick<
11201105
Slice<
11211106
State,
1122-
GetCaseReducers<State, Name, ReducerPath, CreatorMap, CaseReducers>,
1107+
GetCaseReducers<CaseReducers>,
11231108
Name,
11241109
CurrentReducerPath,
11251110
Selectors

0 commit comments

Comments
 (0)