Suggestion: improve ergonomics of *InfiniteOptions
types
#8484
Unanswered
OliverJAsh
asked this question in
General
Replies: 1 comment 1 reply
-
using the defaults doesn’t really help much because using them will make features where type inference is necessary, like We use Moving to a discussion. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
The docs suggest using
infiniteQueryOptions
to abstract infinite query options. For example:However, when using TypeScript's isolated declarations (
isolatedDeclarations
), all module exports must have type annotations. For this reason it would be preferable to use a type annotation rather than theinfiniteQueryOptions
type constructor.The problem with this, however, is it's very verbose:
Except for the first and last type parameters provided to
UnusedSkipTokenInfiniteOptions
, all the others could theoretically just use the defaults. However, we're forced to provide them because we need to provideTPageParam
(the last type parameter), otherwise it would default tounknown
.Given more TypeScript users will likely be looking to enable isolated declarations in the future and thus be required to add type annotations, I wonder if we could make these types more ergonomic.
One idea would be to move the position of the
TPageParam
type parameter in the*InfiniteOptions
types, so we can benefit from defaults. For example, if it was moved from last to second position then the example above would look much better:Your minimal, reproducible example
N/A
Steps to reproduce
N/A
Expected behavior
N/A
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
N/A
Tanstack Query adapter
None
TanStack Query version
N/A
TypeScript version
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions