Skip to content

fix: exclude SkipToken from infinite query getOptions queryFn type - #76

Open
LudvigHz wants to merge 1 commit into
HuolalaTech:mainfrom
LudvigHz:fix/infinite-get-options-skip-token
Open

fix: exclude SkipToken from infinite query getOptions queryFn type#76
LudvigHz wants to merge 1 commit into
HuolalaTech:mainfrom
LudvigHz:fix/infinite-get-options-skip-token

Conversation

@LudvigHz

Copy link
Copy Markdown

Problem

getOptions (and therefore getFetchOptions) already excludes SkipToken from the returned queryFn type for regular queries:

queryFn?: Exclude<UseQueryOptions<TFnData, TError, TFnData, QueryKey>['queryFn'], SkipToken>

but the infinite query branch does not. Since @tanstack/react-query v5.62, the suspense hooks reject skipToken in queryFn (UseSuspenseInfiniteQueryOptions omits it), so this fails to typecheck:

useSuspenseInfiniteQuery(myInfiniteQuery.getFetchOptions(variables))
// Type 'typeof skipToken' is not assignable to type 'QueryFunction<...>'

Fix

Apply the same Exclude<..., SkipToken> to the infinite branch of getOptions, mirroring the regular-query branch. Types-only change; tsc -b and the jest suite pass.

🤖 Generated with Claude Code

… queryFn type

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant