Skip to content

Wrong default for TData in UseInfiniteQueryOptions #11143

Description

@jbgrim

Describe the bug

The default type for UseInfiniteQueryOptions TData template argument is TQueryFnData, which is wrong.

The issue is that typescript is not able to retrieve the correct types due to this inconsistency, which make one rewrite manually the signature for each use of this type.

Your minimal, reproducible example

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbwLACg5wJIDsBmwvAwCmAIgIYxkA0q6ArgM5HZ4HECKdRUAnjWnACqTFvkJFO3HgHkwMYBCwN+AXzg4oEEHABEAAUpLKAYwDWAeihEyxmAFoAjl146A3KlQweYInAAKZADmRAA8ACoAfHAAvIi0cFYMdAA2MAwAXHBhANoAuu4CWEQAHjAA-JkMMFD4gXAAPnBYKckF6MYQdFgwmc0gAEbcBSoFXj5wAKIAbkTdMXGFZCBEldW1bXAAJhQrcFU1WIHDBZ7evgBiwKncDPPIAmBBu32DUBuPwQBydAPcvT+vY4eFBkBg8LDGdRdWwKLBwYIwaazGAAGWAVQAgmBgAAKCByWEZOCXa5QBgASkyfk0IHRoQCwRCSO6ESi93QVhgdCgcPZ6ASRCSqSJeX4-KaJR6TRaYv5HS6UoADLKRqgVMCSpBYFCIfJFHBGMxcGJiMzUeiYJJeDj4nhSUSScQybL8XqlBV-GRYMAyMkQsIjaxxFaZATFAwQgzQmbWRF+OSFu1w-AnFJ5obRGwJM4eJGnkyZiyIji+ehU7wANJEHiZbI6IiFtI6Ki6fBB4hoqrN9RXJ0MXKyss585YTIluAfIgBKBLOAqBPRCLxcUIs2dmBY3Gl8VwAB0+7tfcHO8nmUn06Wx-Q8+PJp9ySjF5AmQAjMeEZ9JY+vUsx8lQTAUYtpOFIxEuAjiv+VRRruRSlHAZQTk8DC7sksyBDAAAWcAANRwC+cCZF0mxEKwRCbMe+67q6hIquSJwCJy3JwuWPDDKgQA

Steps to reproduce

The typesrcipt compiler shows errors when UseInfiniteQueryOptions and useInfiniteQuery are mixed.

Expected behavior

The default type for UseInfiniteQueryOptions should instead be InfiniteData<TQueryFnData> to match the useInfiniteQuery template defaults.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Typescript

Tanstack Query adapter

No response

TanStack Query version

v5.101.4

TypeScript version

v6.0.3

Additional context

The problem is the same with UseSuspenseInfiniteQueryOptions.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions