File tree 3 files changed +41
-18
lines changed
3 files changed +41
-18
lines changed Original file line number Diff line number Diff line change @@ -439,10 +439,24 @@ export interface ScopedMutator {
439
439
* @typeParam Data - The type of the data related to the key
440
440
* @typeParam MutationData - The type of the data returned by the mutator
441
441
*/
442
- export type KeyedMutator < Data > = < MutationData = Data > (
443
- data ?: Data | Promise < Data | undefined > | MutatorCallback < Data > ,
444
- opts ?: boolean | MutatorOptions < Data , MutationData >
445
- ) => Promise < Data | MutationData | undefined >
442
+ export type KeyedMutator < Data > = {
443
+ (
444
+ data ?: Data | Promise < Data | undefined > | MutatorCallback < Data > ,
445
+ opts ?: boolean | MutatorOptions < Data , Data >
446
+ ) : Promise < Data | undefined >
447
+ < MutationData = Data > (
448
+ data :
449
+ | MutationData
450
+ | Promise < MutationData | undefined >
451
+ | MutatorCallback < MutationData > ,
452
+ opts : Omit < MutatorOptions < Data , MutationData > , 'populateCache' > & {
453
+ populateCache : (
454
+ result : MutationData ,
455
+ currentData : Data | undefined
456
+ ) => Data
457
+ }
458
+ ) : Promise < Data | MutationData | undefined >
459
+ }
446
460
447
461
export type SWRConfiguration <
448
462
Data = any ,
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ import {
19
19
import type {
20
20
BareFetcher ,
21
21
SWRHook ,
22
- MutatorCallback ,
23
22
Middleware ,
24
23
GlobalState
25
24
} from '../_internal'
@@ -238,16 +237,9 @@ export const infinite = (<Data, Error>(useSWRNext: SWRHook) =>
238
237
config
239
238
)
240
239
241
- const mutate = useCallback (
240
+ const mutate = useCallback < SWRInfiniteKeyedMutator < Data [ ] > > (
242
241
// eslint-disable-next-line func-names
243
- function < T = Data [ ] > (
244
- data ?:
245
- | undefined
246
- | Data [ ]
247
- | Promise < Data [ ] | undefined >
248
- | MutatorCallback < Data [ ] > ,
249
- opts ?: undefined | boolean | SWRInfiniteMutatorOptions < Data [ ] , T >
250
- ) {
242
+ function ( data ?: any , opts ?: any ) {
251
243
// When passing as a boolean, it's explicitly used to disable/enable
252
244
// revalidation.
253
245
const options =
Original file line number Diff line number Diff line change @@ -47,10 +47,27 @@ interface SWRInfiniteRevalidateFn<Data = any> {
47
47
( data : Data , key : Arguments ) : boolean
48
48
}
49
49
50
- export type SWRInfiniteKeyedMutator < Data > = < MutationData = Data > (
51
- data ?: Data | Promise < Data | undefined > | MutatorCallback < Data > ,
52
- opts ?: boolean | SWRInfiniteMutatorOptions < Data , MutationData >
53
- ) => Promise < Data | MutationData | undefined >
50
+ export type SWRInfiniteKeyedMutator < Data > = {
51
+ (
52
+ data ?: Data | Promise < Data | undefined > | MutatorCallback < Data > ,
53
+ opts ?: boolean | SWRInfiniteMutatorOptions < Data , Data >
54
+ ) : Promise < Data | undefined >
55
+ < MutationData = Data > (
56
+ data :
57
+ | MutationData
58
+ | Promise < MutationData | undefined >
59
+ | MutatorCallback < MutationData > ,
60
+ opts : Omit <
61
+ SWRInfiniteMutatorOptions < Data , MutationData > ,
62
+ 'populateCache'
63
+ > & {
64
+ populateCache : (
65
+ result : MutationData ,
66
+ currentData : Data | undefined
67
+ ) => Data
68
+ }
69
+ ) : Promise < Data | MutationData | undefined >
70
+ }
54
71
55
72
export interface SWRInfiniteMutatorOptions < Data = any , MutationData = Data >
56
73
extends Omit < MutatorOptions < Data , MutationData > , 'revalidate' > {
You can’t perform that action at this time.
0 commit comments