Skip to content

Conversation

@NamesMT
Copy link
Contributor

@NamesMT NamesMT commented Oct 17, 2025

Resolves #4462

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

Additional context

TS seems to does not raise an error when R doesn't actually extends HandlerResponse<any>, and implicitly type R as HandlerResponse<any> directly for cases where R is non-extending.

This PR checks for a case where R might be void, and assign it as non-typed Response, i.e.: the default value, so it prevents the created middleware being HandlerResponse<any> and broke some types chain like direct .use.

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.36%. Comparing base (5eb7c15) to head (7b7558a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4465   +/-   ##
=======================================
  Coverage   91.36%   91.36%           
=======================================
  Files         173      173           
  Lines       11146    11146           
  Branches     3214     3214           
=======================================
  Hits        10183    10183           
  Misses        962      962           
  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.

@NamesMT NamesMT marked this pull request as draft October 17, 2025 12:15
@NamesMT NamesMT force-pushed the fix/useCreateMiddleware branch from e33ebba to 4e679b5 Compare October 17, 2025 12:18
@NamesMT NamesMT marked this pull request as ready for review October 17, 2025 12:18
Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

@NamesMT Thank you!

@yusukebe yusukebe merged commit 8774bf9 into honojs:main Oct 17, 2025
20 checks passed
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.

[4.10.0] cannot .use middleware created from createMiddleware that doesn't return anything

2 participants