-
-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better typesafety for useInfiniteQuery
#2126
base: main
Are you sure you want to change the base?
Better typesafety for useInfiniteQuery
#2126
Conversation
👷 Deploy request for openapi-ts pending review.Visit the deploys page to approve it
|
|
Yes, I agree with this PR. |
@@ -947,6 +948,7 @@ describe("client", () => { | |||
{ | |||
getNextPageParam: (lastPage) => lastPage.nextPage, | |||
initialPageParam: 0, | |||
pageParamName: "cursor", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe here we could use a different param name other than the default one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure what you mean by "the default one". The schema only provides cursor
and limit
as parameters, so any other param name here will trigger a type error (due to the changes in this PR). Or are you suggesting a separate schema for the second test?
Changes
Makes
pageParamName
typesafe and required. This PR also removes the fallbacks forpageParamName
andpageParam
, because they shouldn't have default values in the first place (and they're also no longer needed).The
should use custom cursor params
test is also removed, because I believe that it shouldn't be allowed now that the param is typesafe. Users can always cast the type if they think the schema isn't right.How to Review
Most of the changes here are type-level. I'm still not very familiar with the type utilities, so if there are any mistakes let me know.
Checklist
docs/
updated (if necessary)pnpm run update:examples
run (only applicable for openapi-typescript)