@@ -310,11 +310,15 @@ export type MutatorCallback<Data = any> = (
310
310
currentData ?: Data
311
311
) => Promise < undefined | Data > | undefined | Data
312
312
313
- export type MutatorOptions < Data = any > = {
313
+ /**
314
+ * @typeParam Data - The type of the data related to the key
315
+ * @typeParam MutationData - The type of the data returned by the mutator
316
+ */
317
+ export type MutatorOptions < Data = any , MutationData = Data > = {
314
318
revalidate ?: boolean
315
319
populateCache ?:
316
320
| boolean
317
- | ( ( result : any , currentData : Data | undefined ) => Data )
321
+ | ( ( result : MutationData , currentData : Data | undefined ) => Data )
318
322
optimisticData ?:
319
323
| Data
320
324
| ( ( currentData : Data | undefined , displayedData : Data | undefined ) => Data )
@@ -365,23 +369,38 @@ export type MutatorWrapper<Fn> = Fn extends (
365
369
366
370
export type Mutator < Data = any > = MutatorWrapper < MutatorFn < Data > >
367
371
368
- export interface ScopedMutator < Data = any > {
369
- < T = Data > (
372
+ export interface ScopedMutator {
373
+ /**
374
+ * @typeParam Data - The type of the data related to the key
375
+ * @typeParam MutationData - The type of the data returned by the mutator
376
+ */
377
+ < Data = any , MutationData = Data > (
370
378
matcher : ( key ?: Arguments ) => boolean ,
371
- data ?: T | Promise < T > | MutatorCallback < T > ,
372
- opts ?: boolean | MutatorOptions < Data >
373
- ) : Promise < Array < T | undefined > >
374
- < T = Data > (
379
+ data ?: MutationData | Promise < MutationData > | MutatorCallback < MutationData > ,
380
+ opts ?: boolean | MutatorOptions < Data , MutationData >
381
+ ) : Promise < Array < MutationData | undefined > >
382
+ /**
383
+ * @typeParam Data - The type of the data related to the key
384
+ * @typeParam MutationData - The type of the data returned by the mutator
385
+ */
386
+ < Data = any , T = Data > (
375
387
key : Arguments ,
376
388
data ?: T | Promise < T > | MutatorCallback < T > ,
377
- opts ?: boolean | MutatorOptions < Data >
389
+ opts ?: boolean | MutatorOptions < Data , T >
378
390
) : Promise < T | undefined >
379
391
}
380
392
381
- export type KeyedMutator < Data > = (
382
- data ?: Data | Promise < Data | undefined > | MutatorCallback < Data > ,
383
- opts ?: boolean | MutatorOptions < Data >
384
- ) => Promise < Data | undefined >
393
+ /**
394
+ * @typeParam Data - The type of the data related to the key
395
+ * @typeParam MutationData - The type of the data returned by the mutator
396
+ */
397
+ export type KeyedMutator < Data > = < MutationData > (
398
+ data ?:
399
+ | MutationData
400
+ | Promise < MutationData | undefined >
401
+ | MutatorCallback < MutationData > ,
402
+ opts ?: boolean | MutatorOptions < Data , MutationData >
403
+ ) => Promise < MutationData | undefined >
385
404
386
405
export type SWRConfiguration <
387
406
Data = any ,
0 commit comments