@@ -19,7 +19,7 @@ type AsyncThunksArgs<S, E, D extends Dispatch = Dispatch> = {
19
19
export function createAsyncThunk <
20
20
ActionType extends string ,
21
21
Returned ,
22
- ActionParams = never ,
22
+ ActionParams = void ,
23
23
TA extends AsyncThunksArgs < any , any , any > = AsyncThunksArgs <
24
24
unknown ,
25
25
unknown ,
@@ -34,7 +34,7 @@ export function createAsyncThunk<
34
34
) {
35
35
const fulfilled = createAction (
36
36
type + '/fulfilled' ,
37
- ( result : Returned , args : ActionParams , requestId : string ) => {
37
+ ( result : Returned , requestId : string , args : ActionParams ) => {
38
38
return {
39
39
payload : result ,
40
40
meta : { args, requestId }
@@ -44,7 +44,7 @@ export function createAsyncThunk<
44
44
45
45
const pending = createAction (
46
46
type + '/pending' ,
47
- ( args : ActionParams , requestId : string ) => {
47
+ ( requestId : string , args : ActionParams ) => {
48
48
return {
49
49
payload : undefined ,
50
50
meta : { args, requestId }
@@ -54,7 +54,7 @@ export function createAsyncThunk<
54
54
55
55
const finished = createAction (
56
56
type + '/finished' ,
57
- ( args : ActionParams , requestId : string ) => {
57
+ ( requestId : string , args : ActionParams ) => {
58
58
return {
59
59
payload : undefined ,
60
60
meta : { args, requestId }
@@ -64,7 +64,7 @@ export function createAsyncThunk<
64
64
65
65
const rejected = createAction (
66
66
type + '/rejected' ,
67
- ( error : Error , args : ActionParams , requestId : string ) => {
67
+ ( error : Error , requestId : string , args : ActionParams ) => {
68
68
return {
69
69
payload : undefined ,
70
70
error,
@@ -82,7 +82,7 @@ export function createAsyncThunk<
82
82
const requestId = nanoid ( )
83
83
84
84
try {
85
- dispatch ( pending ( args , requestId ) )
85
+ dispatch ( pending ( requestId , args ) )
86
86
// TODO Also ugly types
87
87
const result = ( await payloadCreator ( args , {
88
88
dispatch,
@@ -92,13 +92,13 @@ export function createAsyncThunk<
92
92
} as TA ) ) as Returned
93
93
94
94
// TODO How do we avoid errors in here from hitting the catch clause?
95
- return dispatch ( fulfilled ( result , args , requestId ) )
95
+ return dispatch ( fulfilled ( result , requestId , args ) )
96
96
} catch ( err ) {
97
97
// TODO Errors aren't serializable
98
- dispatch ( rejected ( err , args , requestId ) )
98
+ dispatch ( rejected ( err , requestId , args ) )
99
99
} finally {
100
100
// TODO IS there really a benefit from a "finished" action?
101
- dispatch ( finished ( args , requestId ) )
101
+ dispatch ( finished ( requestId , args ) )
102
102
}
103
103
}
104
104
}
0 commit comments