Skip to content

Commit 409a222

Browse files
committed
refactor(types): simplify placeholderData type definition by removing NonFunctionGuard
This simplification is possible due to the introduction of generic runtime utilities that handle value-or-function resolution. The new `resolveValueOrFunction()` utility handles the distinction between direct values and functions at runtime with proper type safety, eliminating the need for complex type-level guards.
1 parent 2421a38 commit 409a222

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

packages/query-core/src/types.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ export type QueryFunctionContext<
162162

163163
export type InitialDataFunction<T> = () => T | undefined
164164

165-
type NonFunctionGuard<T> = T extends Function ? never : T
166-
167165
export type PlaceholderDataFunction<
168166
TQueryFnData = unknown,
169167
TError = DefaultError,
@@ -420,13 +418,8 @@ export interface QueryObserverOptions<
420418
* If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided.
421419
*/
422420
placeholderData?:
423-
| NonFunctionGuard<TQueryData>
424-
| PlaceholderDataFunction<
425-
NonFunctionGuard<TQueryData>,
426-
TError,
427-
NonFunctionGuard<TQueryData>,
428-
TQueryKey
429-
>
421+
| TQueryData
422+
| PlaceholderDataFunction<TQueryData, TError, TQueryData, TQueryKey>
430423

431424
_optimisticResults?: 'optimistic' | 'isRestoring'
432425

0 commit comments

Comments
 (0)