Comments (3)
After spending the whole morning trying to debug this issues, what ever I'm tried I can't get getNextPageParam
to inferred typed from queryFn
.
Turns out it's my linter, it auto sort object key alphabetically.
So note to myself and other who sees this, order does matter!
Below is the exact same code, but getNextPageParam
is the first key on the object, lastPage ended up to be unknown
.
Reference:
microsoft/TypeScript#56297
from query.
pageParam
is unknown
because you take away type inference by providing to 2 of the 5 type parameters manually. TypeScript can't do partial type inference yet, so once you define one type parameter, the rest will fall back to the default value.
The best fix is to use type inference all the way through. I've written about this here: https://tkdodo.eu/blog/react-query-and-type-script#infer-all-the-things
and it's also in the docs: https://tanstack.com/query/v5/docs/framework/react/typescript#type-inference
so really, just remove the <>
and everything infers nicely:
from query.
Wow would have never guessed this, but the order of the properties was also my issue as well. Thanks :)
from query.
Related Issues (20)
- Solid-Query example returns repositoryQuery.data is undefined HOT 2
- Bug: Dependent Query doesn't work with solid-js SSR HOT 5
- Weird bug in useQuery's select HOT 1
- Bug: Cannot read properties of null (reading '__previousQueryOptions') HOT 4
- [Bug?]: Result type of combine works not as expected HOT 1
- Bug: Error when hydrating an query that threw error HOT 1
- useQuery() hook vulnerable to type errors HOT 1
- [svelte-query] `getQueryData`/`setQueryData` fail to infer query data type from `queryOptions` HOT 3
- ESLint Plugin: Flat Config Support HOT 2
- [react-query][Bug?]When invalidating useSuspenseQuery queries with invalidateQueries, the refetch process does not run. HOT 1
- useIsFetching stops tracking queries immediately HOT 1
- Typescript issue with queryOptions and usePrefetchQuery HOT 2
- No QueryClient set, use QueryClientProvider to set one
- Cannot read properties of null (reading 'useRef') with Vite Module Federation HOT 1
- docs: make the incompatibility of `skipToken` and `refetch` more detailed HOT 1
- "React Example: Nextjs Suspense Streaming" doesn't work HOT 1
- `useSuspenseQuery` does not retry after `fetchQuery` returned an error HOT 4
- invoking `suspense()` with `enabled: false` will wait infinite while ssr HOT 3
- Vercel build error when using HydrationBoundary HOT 4
- No information about matchQuery in the docs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from query.