Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): replace Hono with HonoBase to get better consistency of types #3580

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

m-shaka
Copy link
Contributor

@m-shaka m-shaka commented Oct 29, 2024

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

I don't understand the cause well, but this change resolved #3485 (comment)

Also, I removed mutual dependency between Hono and HonoBase:

graph TD;
    HonoBase-->HandlerInterface;
    HandlerInterface-->Hono;
    Hono-->HonoBase;
Loading

There are subclasses of HonoBase other than Hono, so return types of HandlerInterface should not be Hono.

@yusukebe yusukebe changed the title fix(types): replace Hono with HonoBase to get better consistency of t… fix(types): replace Hono with HonoBase to get better consistency of types Oct 29, 2024
@yusukebe
Copy link
Member

@m-shaka Thanks! Great!

What I find a little curious is that the type of the value returned by app.get() is not HonoBase, but Hono. This is ideal behavior, but I couldn't figure out why this is the following.

CleanShot 2024-10-29 at 14 47 36@2x

@yusukebe
Copy link
Member

@m-shaka

The behavior I commented is ideal, so if it is the correct behavior you expected, let's go with it.

@m-shaka
Copy link
Contributor Author

m-shaka commented Oct 29, 2024

What I find a little curious is that the type of the value returned by app.get() is not HonoBase, but Hono.

I guess this is because HonoBase is named as Hono when it's defined. If you rename HonoBase Hono, you'll see HonoBase there

class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.71%. Comparing base (0e0b473) to head (d36134e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3580    +/-   ##
========================================
  Coverage   94.71%   94.71%            
========================================
  Files         158      158            
  Lines        9535     9535            
  Branches     2774     2886   +112     
========================================
  Hits         9031     9031            
  Misses        504      504            

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

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

@m-shaka Thanks! Let's go with this.

@yusukebe yusukebe merged commit 964aa54 into honojs:main Oct 29, 2024
16 checks passed
TinsFox pushed a commit to TinsFox/hono that referenced this pull request Nov 11, 2024
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.

Hono RPC client - types inferred incorrectly
2 participants