Skip to content

feat(client): add PickResponseByStatusCode type#4791

Merged
yusukebe merged 1 commit intomainfrom
feat/client-pick-response-by-status-code
Mar 23, 2026
Merged

feat(client): add PickResponseByStatusCode type#4791
yusukebe merged 1 commit intomainfrom
feat/client-pick-response-by-status-code

Conversation

@yusukebe
Copy link
Copy Markdown
Member

@yusukebe yusukebe commented Mar 5, 2026

Fixes #4590

Adding PickResponseByStatusCode to limit the status code for the Hono client in case of using a custom fetch that only returns a 200 response.

Usage:

type AppSuccessOnly = PickResponseByStatusCode<typeof app, 200>
const client = hc<AppSuccessOnly>('http://localhost')

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2026

Bundle size check

main (18cc595) #4791 (f17d41a) +/-
Bundle Size (B) 18,483B 18,483B 0B
Bundle Size (KB) 18.05K 18.05K 0K

Compiler Diagnostics (tsc)

main (18cc595) #4791 (f17d41a) +/-
Files 303 303 0
Lines 141,272 141,303 31
Identifiers 129,303 129,349 46
Symbols 269,252 269,273 21
Types 198,829 198,861 32
Instantiations 614,273 614,305 32
Memory used 342,090K 334,337K -7,753K
I/O read 0.03s 0.03s 0s
I/O write 0s 0s 0s
Parse time 0.82s 0.73s -0.09s
Bind time 0.36s 0.3s -0.06s
Check time 2.7s 2.44s -0.26s
Emit time 0s 0s 0s
Total time 3.88s 3.47s -0.41s

Compiler Diagnostics (typescript-go)

main (18cc595) #4791 (f17d41a) +/-
Files 303 303 0
Lines 145,453 145,484 31
Identifiers 130,894 130,940 46
Symbols 391,533 390,134 -1,399
Types 366,137 366,169 32
Instantiations 988,802 988,834 32
Memory used 252,654K 251,879K -775K
Memory allocs 2,558,454 2,558,522 68
Config time 0.001s 0.001s 0s
Parse time 0.094s 0.094s 0s
Bind time 0.037s 0.037s 0s
Check time 0.618s 0.614s -0.004s
Emit time 0s 0s 0s
Total time 0.798s 0.796s -0.002s

Reported by octocov

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2026

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 33,818.96 46,221.43 30,102.41 25,133.05
hono (current) bun 34,468.76 45,791.63 31,566.86 26,047.78
Change +1.92% -0.93% +4.86% +3.64%

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.47%. Comparing base (18cc595) to head (5def229).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4791   +/-   ##
=======================================
  Coverage   91.47%   91.47%           
=======================================
  Files         177      177           
  Lines       11578    11578           
  Branches     3368     3367    -1     
=======================================
  Hits        10591    10591           
  Misses        986      986           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@baseballyama baseballyama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your help! By leveraging this type, it seems possible to primarily use a type that only accepts 2xx responses, and switch to a type that includes 4xx and 5xx only when necessary.

@yusukebe
Copy link
Copy Markdown
Member Author

@baseballyama Thank you for reviewing. I'll merge this change and include it in the next patch version.

@yusukebe yusukebe merged commit d1722e3 into main Mar 23, 2026
20 checks passed
@yusukebe yusukebe deleted the feat/client-pick-response-by-status-code branch March 23, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Since PR #4393, success response types can no longer be resolved without explicit status/ok checks

2 participants