Skip to content

Commit 251bf4a

Browse files
committed
docs(core): enhance resolveOption function documentation
Add detailed explanations of NonFunction constraint benefits, overload behavior for optional vs required values, and improved type safety guarantees.
1 parent 87398fd commit 251bf4a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/query-core/src/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ export function noop() {}
9393
* throughout the codebase and provides a clean way to handle the common pattern where
9494
* options can be static values or dynamic functions.
9595
*
96+
* The NonFunction<T> constraint eliminates ambiguity by ensuring T can never be a function
97+
* type. This makes the value-or-function pattern type-safe and unambiguous.
98+
*
99+
* The function provides two overloads: one that includes `| undefined` for optional values
100+
* (where the value might not be provided), and another without `| undefined` for required
101+
* values. This allows proper type inference for both optional config parameters and
102+
* required ones while maintaining type safety.
103+
*
96104
* @template T - The type of the resolved value (constrained to non-function types)
97105
* @template TArgs - Array of argument types when resolving function variants
98106
* @param value - Either a direct value of type T or a function that returns T

0 commit comments

Comments
 (0)