Infinite query error when getNextPageParam is not after queryFn #7222
Send to my agentDescribe the bug#
linksQueryOptions throw a type error when getNextPageParam is not after queryFn.
Your minimal, reproducible example#
Steps to reproduce#
- Go to playground
- Move
getNextPageParamafterqueryFnand the error should gone
Expected behavior#
Do not throw an error.
How often does this bug happen?#
Every time
Screenshots or Videos#
No response
Platform#
N/A
Tanstack Query adapter#
react-query
TanStack Query version#
5.28.14
TypeScript version#
5.2.2
Additional context#
No response
TkDodo added labelstypes
On the spot, I'm not sure what
getNextPageParamdepends on - but I assume that it might depend on the return type ofqueryFn. In the reported situation thequeryFnis context-sensitive (it has unannotated parameters). If we introduce that extra change to the simplified repro above we end up with an issue too: https://www.typescriptlang.org/play?ts=5.4.4#code/C4TwDgpgBAsiDyAjAVhAxsAPAFQHxQF4oBvAWACgoowAnAewBMBXNCALigAoBDDgZ2A0AlgDsA5gEpC+bAG4KVNHRF8mAW3ZcG3YLyjYpBfADc6QhvPIBfSxSUrgUAGZ06hKDgA0uTnRQc4JFQMHFxDfDJKKHsBKFEwJkciP2QAOlpGFghOACIciUsqFNSY9Wz4xIKKGwoKFzpOSKoM5lYOHnCoAEYAJgBmTwVo5VUNdorgTonU4DoAMSEADwgGTglB6yryOtdGodKxrgmpkQTgGfmllbWN5vpWzQ7pbv6Nqy2gAah got it. I remember there was an open TS issue but I couldn't find it. I think we're fine having this as a known limitation.
TkDodo closed this
TkDodo added labelsknown limitation
TkDodo added labelsupstream
Sign in to join this conversation.
I thought it's a TS limitation, but it works in this minimal consume/produce example:
https://www.typescriptlang.org/play?#code/C4TwDgpgBAsiDyAjAVhAxsAPAFQHxQF4oBvAWACgoowAnAewBMBXNCALigAoBKQ-bADQUqaOgDsAzkwC27LgwCGwBR2y8C+AG50AlgwoBfChVGTgUAGZ06hKDgG5OdFBzhJUGHLnX4ylKKYS5jpiYEzmRM7IAHS0jCwQPMJQUdGBMokhYcDchsbkVnScflRxzKwcPHxQAIwATADMQv7pspVZ4T5QHcDRwHQAYjoAHhAMSeQGueQUhcXJrXKcPV09fYMjYzzNpfTlS131DYbcQA
Could still be a limitation given that our need is more complex. I think @Andarist would know this :)