You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(parseResponse): should not include error responses in result (#4348)
* fix(client): improve parseResponse type inference for conditional responses
Previously, parseResponse would infer union types for routes that return
different response types based on conditions (e.g., success vs error responses).
This was incorrect because parseResponse throws errors for non-OK responses
and should only return the success response type.
Changes:
- Use Extract<> utility type to filter success status code responses from union types
- Add fallback logic for responses without explicit success status codes
- Update test cases to match the corrected behavior
- Add comprehensive test case for conditional response type inference
The fix ensures that parseResponse(client['conditional-route'].$get()) correctly
infers only the success response type instead of a union of all possible response types.
* ci: apply automated fixes
* test(client): fix parsedResponse test issue and remove unused test case
* fix: minor type error in current runtime version
* chore: add more test cases
* feat: add `FilterClientResponses` util
* fix(parseResponse): should not include error responses in result
* chore: refactor to type-only tests and ordering
* chore: rename type util and add JSDOC describe
---------
Co-authored-by: Zed tse <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
0 commit comments