WIP: infer errors from Throws returns#10034
WIP: infer errors from Throws returns#10034shkumbinhasani wants to merge 1 commit intoTanStack:mainfrom
Conversation
|
📝 WalkthroughWalkthroughIntroduces a comprehensive TypeScript type system for expressing and extracting error types from function return types using phantom types ( Changes
Suggested labels
Suggested reviewers
Poem
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🧰 Additional context used🧠 Learnings (4)📓 Common learnings📚 Learning: 2025-08-19T03:18:18.303ZApplied to files:
📚 Learning: 2025-11-02T22:52:33.071ZApplied to files:
📚 Learning: 2025-11-22T09:06:05.219ZApplied to files:
🧬 Code graph analysis (4)packages/react-query/src/useQuery.ts (2)
packages/react-query/src/__tests__/mutationOptions.test-d.tsx (1)
packages/react-query/src/useMutation.ts (3)
packages/react-query/src/__tests__/useQuery.test-d.tsx (2)
🔇 Additional comments (13)
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 |
| any, | ||
| TQueryKey | ||
| >, | ||
| TQueryFnData = StripThrows<Awaited<ReturnType<TQueryFn>>>, |
There was a problem hiding this comment.
isn’t the big problem here that we would need to do this on all functions that can produce TQueryFnData like queryOptions, usePrefetchQuery, the imperative methods on the queryClient etc ... ?
Summary
Throwsreturn annotations when providedanyand stripThrowsto avoid pollution in data inferencePromise<any>fallbackTesting
pnpm --filter @tanstack/react-query test:types(fails intest:types:tscurrentatpackages/react-query/src/__tests__/useQuery.test.tsx:2186: NotifyOnChangeProps type mismatch)Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.