Skip to content

Commit

Permalink
fix: fix the type of the argument of KeyedMutator for populateCache
Browse files Browse the repository at this point in the history
  • Loading branch information
Key5n committed Apr 8, 2024
1 parent 79445e4 commit d2a4282
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/_internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,12 @@ export interface ScopedMutator {
* @typeParam MutationData - The type of the data returned by the mutator
*/
export type KeyedMutator<Data> = <MutationData = Data>(
data?: Data | Promise<Data | undefined> | MutatorCallback<Data>,
data?:
| MutationData
| Promise<MutationData | undefined>
| MutatorCallback<MutationData>,
opts?: boolean | MutatorOptions<Data, MutationData>
) => Promise<Data | MutationData | undefined>
) => Promise<MutationData | undefined>

export type SWRConfiguration<
Data = any,
Expand Down
11 changes: 5 additions & 6 deletions src/infinite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,12 @@ export const infinite = (<Data, Error>(useSWRNext: SWRHook) =>

const mutate = useCallback(
// eslint-disable-next-line func-names
function <T = Data[]>(
function <MutationData = Data[]>(
data?:
| undefined
| Data[]
| Promise<Data[] | undefined>
| MutatorCallback<Data[]>,
opts?: undefined | boolean | SWRInfiniteMutatorOptions<Data[], T>
| MutationData
| Promise<MutationData | undefined>
| MutatorCallback<MutationData>,
opts?: boolean | SWRInfiniteMutatorOptions<Data[], MutationData>
) {
// When passing as a boolean, it's explicitly used to disable/enable
// revalidation.
Expand Down

0 comments on commit d2a4282

Please sign in to comment.