Skip to content

Commit aa29b16

Browse files
committed
refactor: update more callback signatures to use MaybePromise<T>
This commit continues the standardization of using the `MaybePromise<T>` type across the codebase, updating the callback signatures for `retryer.ts`, `types.ts`, and `createPersister.ts.`
1 parent b7383db commit aa29b16

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/query-core/src/retryer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { focusManager } from './focusManager'
22
import { onlineManager } from './onlineManager'
33
import { pendingThenable } from './thenable'
44
import { isServer, sleep } from './utils'
5-
import type { CancelOptions, DefaultError, NetworkMode } from './types'
5+
import type { CancelOptions, DefaultError, MaybePromise, NetworkMode } from './types'
66

77
// TYPES
88

99
interface RetryerConfig<TData = unknown, TError = DefaultError> {
10-
fn: () => TData | Promise<TData>
10+
fn: () => MaybePromise<TData>
1111
initialPromise?: Promise<TData>
1212
abort?: () => void
1313
onError?: (error: TError) => void

packages/query-core/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export type QueryFunction<
9898
T = unknown,
9999
TQueryKey extends QueryKey = QueryKey,
100100
TPageParam = never,
101-
> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => T | Promise<T>
101+
> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => MaybePromise<T>
102102

103103
export type StaleTime<
104104
TQueryFnData = unknown,
@@ -125,12 +125,12 @@ export type QueryPersister<
125125
queryFn: QueryFunction<T, TQueryKey, never>,
126126
context: QueryFunctionContext<TQueryKey>,
127127
query: Query,
128-
) => T | Promise<T>
128+
) => MaybePromise<T>
129129
: (
130130
queryFn: QueryFunction<T, TQueryKey, TPageParam>,
131131
context: QueryFunctionContext<TQueryKey>,
132132
query: Query,
133-
) => T | Promise<T>
133+
) => MaybePromise<T>
134134

135135
export type QueryFunctionContext<
136136
TQueryKey extends QueryKey = QueryKey,

packages/query-persist-client-core/src/createPersister.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export function experimental_createQueryPersister<TStorageValue = string>({
179179
}
180180

181181
async function persisterFn<T, TQueryKey extends QueryKey>(
182-
queryFn: (context: QueryFunctionContext<TQueryKey>) => T | Promise<T>,
182+
queryFn: (context: QueryFunctionContext<TQueryKey>) => MaybePromise<T>,
183183
ctx: QueryFunctionContext<TQueryKey>,
184184
query: Query,
185185
) {

0 commit comments

Comments
 (0)