Skip to content
Source
Sign inSign up
TanStack/query

[svelte-query] infiniteQuery pageParams type is unkown[] #6313

ClosedHugeLetters(GitHub profile, opens in a new tab) opened this issue 1 comment

Describe the bug

Due to this line pageParams on infinite queries have a type of unknown. https://github.com/TanStack/query/blob/603a346d4f5ffaf02f49bf32ac5221029da6f4a1/packages/svelte-query/src/createInfiniteQuery.ts#L19

InfiniteData receives a second generic parameter for a key type but since TPageParam parameter appears later you can't provide it there.

This is just an FIY, it's not a priority issue and it doesn't bother me but I thought you would wanna know.

Your minimal, reproducible example

.

Steps to reproduce

	const iq = createInfiniteQuery({
		queryKey: [],
		queryFn() {
			return 1;
		},
		getNextPageParam() {
			return 1;
		},
		initialPageParam: 0
	});
	$iq.data?.pageParams; // this is unknown[] | undefined but should be number[] | undefined

Expected behavior

.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

.

Tanstack Query adapter

svelte-query

TanStack Query version

5.6.1

TypeScript version

5.2.2

Additional context

No response

  1. we're aware of this - it's not svelte specific though. Adding the additional type parameter would mean that createInfiniteQuery and all hooks in react like useInfiniteQuery would need another type parameter. It's doable but the benefit is minor - it's very unlikely that you need access to pageParams during rendering. They are kind of an internal thing that we store alongside data and pass it to getNextPageParam.

    I would say for now, this is a known limitation that we won't address unless there's a real need / use-case for it.

  2. TkDodo closed this

  3. TkDodo added labelswontfix

  4. TkDodo added labelsknown limitation

Sign in to join this conversation.