Better typesafety for useInfiniteQuery#2126
Better typesafety for useInfiniteQuery#2126patrickariel wants to merge 7 commits intoopenapi-ts:mainfrom
useInfiniteQuery#2126Conversation
✅ Deploy Preview for openapi-ts ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
Yes, I agree with this PR. |
| { | ||
| getNextPageParam: (lastPage) => lastPage.nextPage, | ||
| initialPageParam: 0, | ||
| pageParamName: "cursor", |
There was a problem hiding this comment.
Maybe here we could use a different param name other than the default one?
There was a problem hiding this comment.
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?
|
Anything I can do here to move this forward? |
Changes
Makes
pageParamNametypesafe and required. This PR also removes the fallbacks forpageParamNameandpageParam, because they shouldn't have default values in the first place (and they're also no longer needed).The
should use custom cursor paramstest 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:examplesrun (only applicable for openapi-typescript)