Clarify useSwrQuery caching behavior with select transforms#1625
Clarify useSwrQuery caching behavior with select transforms#1625Copilot wants to merge 1 commit intofeat/ensadmin-projection-infofrom
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
@copilot as for Type Safety Issue Identified, |
... You're absolutely right - by default However, when a Given that:
Should I close this PR since there's no actionable issue to fix? |
|
@copilot I think you are wrong here, changing |
... You're absolutely correct, and I apologize for the confusion. The type assertion The current implementation is correct - the type assertion is a necessary compromise to make the SWR fallback logic work. My original concern was unfounded. This PR can be closed. |
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
useSwrQuerycaching behavior in response to maintainer feedbackTData = TQueryFnData) but has edge case withselectWhy
useSwrQueryandselecttransform cachingTData = TQueryFnDatamakes the type assertion valid in most casesTesting
Notes for Reviewer
Resolution:
The maintainer correctly identified that
TData = TQueryFnDataby default in the function signature (line 60), which means the type assertion on line 97 is correct for the common case where noselectoption is provided.Type Assertion Analysis:
Line 97 in
useSwrQuery.ts:TData = TQueryFnData, sogetQueryData<TData>()returns the correct typeselectis provided (like inuseIndexingStatusWithSwr),TData ≠ TQueryFnData, creating a technical type mismatch. However, this doesn't cause runtime issues because React Query's fallback behavior already handles select transforms correctly.Conclusion:
The current implementation is working as intended. The technical type mismatch when
selectis used doesn't cause practical issues due to React Query's behavior.Pre-Review Checklist (Blocking)
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.