From 9538727e033deaf8efded73191cfbd592d929550 Mon Sep 17 00:00:00 2001 From: Key5n Date: Mon, 8 Apr 2024 22:23:38 +0900 Subject: [PATCH] fix: fix the type of the argument of `KeyedMutator` for `populateCache` --- src/_internal/types.ts | 7 +++++-- src/infinite/index.ts | 11 +++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/_internal/types.ts b/src/_internal/types.ts index 528dae9327..e88039f5f4 100644 --- a/src/_internal/types.ts +++ b/src/_internal/types.ts @@ -440,9 +440,12 @@ export interface ScopedMutator { * @typeParam MutationData - The type of the data returned by the mutator */ export type KeyedMutator = ( - data?: Data | Promise | MutatorCallback, + data?: + | MutationData + | Promise + | MutatorCallback, opts?: boolean | MutatorOptions -) => Promise +) => Promise export type SWRConfiguration< Data = any, diff --git a/src/infinite/index.ts b/src/infinite/index.ts index f410b5befb..6e51f85749 100644 --- a/src/infinite/index.ts +++ b/src/infinite/index.ts @@ -240,13 +240,12 @@ export const infinite = ((useSWRNext: SWRHook) => const mutate = useCallback( // eslint-disable-next-line func-names - function ( + function ( data?: - | undefined - | Data[] - | Promise - | MutatorCallback, - opts?: undefined | boolean | SWRInfiniteMutatorOptions + | MutationData + | Promise + | MutatorCallback, + opts?: boolean | SWRInfiniteMutatorOptions ) { // When passing as a boolean, it's explicitly used to disable/enable // revalidation.