@@ -7,18 +7,14 @@ import type {
7
7
} from './createAsyncThunk'
8
8
import { createAsyncThunk } from './createAsyncThunk'
9
9
import type { CaseReducer } from './createReducer'
10
- import type {
11
- CreatorCaseReducers ,
12
- ReducerCreator ,
13
- ReducerDefinition ,
14
- } from './createSlice'
10
+ import type { ReducerCreator , ReducerDefinition } from './createSlice'
15
11
import { ReducerType } from './createSlice'
16
12
import type { Id } from './tsHelpers'
17
13
18
- export type AsyncThunkSliceReducerConfig <
14
+ export type AsyncThunkSliceReducers <
19
15
State ,
20
- ThunkArg extends any ,
21
- Returned = unknown ,
16
+ ThunkArg ,
17
+ Returned ,
22
18
ThunkApiConfig extends AsyncThunkConfig = { } ,
23
19
> = {
24
20
pending ?: CaseReducer <
@@ -39,6 +35,14 @@ export type AsyncThunkSliceReducerConfig<
39
35
AsyncThunk < Returned , ThunkArg , ThunkApiConfig > [ 'rejected' | 'fulfilled' ]
40
36
>
41
37
>
38
+ }
39
+
40
+ export type AsyncThunkSliceReducerConfig <
41
+ State ,
42
+ ThunkArg ,
43
+ Returned ,
44
+ ThunkApiConfig extends AsyncThunkConfig = { } ,
45
+ > = AsyncThunkSliceReducers < State , ThunkArg , Returned , ThunkApiConfig > & {
42
46
options ?: AsyncThunkOptions < ThunkArg , ThunkApiConfig >
43
47
}
44
48
@@ -116,41 +120,38 @@ export interface AsyncThunkCreator<
116
120
117
121
export type AsyncThunkCreatorExposes <
118
122
State ,
119
- CaseReducers extends CreatorCaseReducers < State > ,
123
+ Definition extends ReducerDefinition ,
120
124
> = {
121
- actions : {
122
- [ ReducerName in keyof CaseReducers ] : CaseReducers [ ReducerName ] extends AsyncThunkSliceReducerDefinition <
123
- State ,
124
- infer ThunkArg ,
125
- infer Returned ,
126
- infer ThunkApiConfig
127
- >
128
- ? AsyncThunk < Returned , ThunkArg , ThunkApiConfig >
129
- : never
130
- }
131
- caseReducers : {
132
- [ ReducerName in keyof CaseReducers ] : CaseReducers [ ReducerName ] extends AsyncThunkSliceReducerDefinition <
133
- State ,
134
- any ,
135
- any ,
136
- any
137
- >
138
- ? Id <
139
- Pick <
140
- Required < CaseReducers [ ReducerName ] > ,
141
- 'fulfilled' | 'rejected' | 'pending' | 'settled'
142
- >
125
+ action : Definition extends AsyncThunkSliceReducerDefinition <
126
+ State ,
127
+ infer ThunkArg ,
128
+ infer Returned ,
129
+ infer ThunkApiConfig
130
+ >
131
+ ? AsyncThunk < Returned , ThunkArg , ThunkApiConfig >
132
+ : never
133
+
134
+ caseReducer: Definition extends AsyncThunkSliceReducerDefinition <
135
+ State ,
136
+ any ,
137
+ any ,
138
+ any
139
+ >
140
+ ? Id <
141
+ Pick <
142
+ Required < Definition > ,
143
+ 'fulfilled' | 'rejected' | 'pending' | 'settled'
143
144
>
144
- : never
145
- }
145
+ >
146
+ : never
146
147
}
147
148
148
149
export const asyncThunkCreator : ReducerCreator < ReducerType . asyncThunk > = {
149
150
type : ReducerType . asyncThunk ,
150
151
create : /* @__PURE__ */ ( ( ) => {
151
152
function asyncThunk (
152
153
payloadCreator : AsyncThunkPayloadCreator < any , any > ,
153
- config : AsyncThunkSliceReducerConfig < any , any > ,
154
+ config : AsyncThunkSliceReducerConfig < any , any , any > ,
154
155
) : AsyncThunkSliceReducerDefinition < any , any > {
155
156
return {
156
157
_reducerDefinitionType : ReducerType . asyncThunk ,
0 commit comments