Skip to content

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

Merged
yusukebe merged 2 commits intohonojs:mainfrom
m-shaka:fix-#3485
Oct 29, 2024
Merged

fix(types): replace Hono with HonoBase to get better consistency of types#3580
yusukebe merged 2 commits intohonojs:mainfrom
m-shaka:fix-#3485

Conversation

@m-shaka
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 = '/'> {

@codecov
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member

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

@yusukebe yusukebe merged commit 964aa54 into honojs:main Oct 29, 2024
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