@@ -121,7 +121,7 @@ export type UseAsyncReturn<
121
121
// Relaxed interface which accept both async and sync functions
122
122
// Accepting sync function is convenient for useAsyncCallback
123
123
const useAsyncInternal = < R , Args extends any [ ] > (
124
- asyncFunction : ( ...args : Args ) => MaybePromise < R > ,
124
+ asyncFunction : ( ( ...args : Args ) => MaybePromise < R > ) | ( ( ) => MaybePromise < R > ) ,
125
125
params : Args ,
126
126
options ?: UseAsyncOptions < R >
127
127
) : UseAsyncReturn < R , Args > => {
@@ -183,7 +183,7 @@ const useAsyncInternal = <R, Args extends any[]>(
183
183
} ;
184
184
185
185
export const useAsync = < R , Args extends any [ ] > (
186
- asyncFunction : ( ...args : Args ) => Promise < R > ,
186
+ asyncFunction : ( ( ...args : Args ) => Promise < R > ) | ( ( ) => Promise < R > ) ,
187
187
params : Args ,
188
188
options ?: UseAsyncOptions < R >
189
189
) : UseAsyncReturn < R , Args > => useAsyncInternal ( asyncFunction , params , options ) ;
@@ -195,7 +195,9 @@ type AddArg<H, T extends any[]> = ((h: H, ...t: T) => void) extends ((
195
195
: never ;
196
196
197
197
export const useAsyncAbortable = < R , Args extends any [ ] > (
198
- asyncFunction : ( ...args : AddArg < AbortSignal , Args > ) => Promise < R > ,
198
+ asyncFunction :
199
+ | ( ( ...args : AddArg < AbortSignal , Args > ) => Promise < R > )
200
+ | ( ( abortSignal : AbortSignal ) => MaybePromise < R > ) ,
199
201
params : Args ,
200
202
options ?: UseAsyncOptions < R >
201
203
) : UseAsyncReturn < R , Args > => {
@@ -229,7 +231,7 @@ export const useAsyncAbortable = <R, Args extends any[]>(
229
231
} ;
230
232
231
233
export const useAsyncCallback = < R , Args extends any [ ] > (
232
- asyncFunction : ( ...args : Args ) => MaybePromise < R >
234
+ asyncFunction : ( ( ...args : Args ) => MaybePromise < R > ) | ( ( ) => MaybePromise < R > )
233
235
) : UseAsyncReturn < R , Args > => {
234
236
return useAsyncInternal (
235
237
asyncFunction ,
0 commit comments