docs(react-query): add caveat for typing getQueriesData#9684
docs(react-query): add caveat for typing getQueriesData#9684TkDodo merged 1 commit intoTanStack:mainfrom
Conversation
WalkthroughClarifies in the React TypeScript docs that type inference from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 6fb352b
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/angular-query-experimental
@tanstack/eslint-plugin-query
@tanstack/query-async-storage-persister
@tanstack/query-broadcast-client-experimental
@tanstack/query-core
@tanstack/query-devtools
@tanstack/query-persist-client-core
@tanstack/query-sync-storage-persister
@tanstack/react-query
@tanstack/react-query-devtools
@tanstack/react-query-next-experimental
@tanstack/react-query-persist-client
@tanstack/solid-query
@tanstack/solid-query-devtools
@tanstack/solid-query-persist-client
@tanstack/svelte-query
@tanstack/svelte-query-devtools
@tanstack/svelte-query-persist-client
@tanstack/vue-query
@tanstack/vue-query-devtools
commit: |
🎯 Changes
The docs explain how to use
queryOptionsto get nice type inference on queries. It explicitly calls out how the type gets attached to thequeryKey, so that evenqueryClient.getQueryData()(which just accepts thequeryKeyand not the full options with thequeryFncan infer the type of the returned data.I was surprised to discover that this does not work for the plural equivalent
queryClient.getQueriesData(). I went to open a bug, and found #8613, which directed me to the docs for this method, which do explain why this does not work.I think it would be good to add the same caveat to the section of the docs where the trick is explained. That's what this PR does. The intention is for the docs to say "here's how to do it, here's a special bonus where you might not think it works but does, and here's a different special case where it does not work".
✅ Checklist
pnpm test:pr.🚀 Release Impact
Summary by CodeRabbit