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(client): do not suggest unnecenssary route path #3126

Closed
wants to merge 4 commits into from

Conversation

EdamAme-x
Copy link
Contributor

@EdamAme-x EdamAme-x commented Jul 11, 2024

Closes #3122

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

@EdamAme-x EdamAme-x marked this pull request as draft July 11, 2024 02:01
Copy link

codecov bot commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.87%. Comparing base (ec58511) to head (681ff14).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3126   +/-   ##
=======================================
  Coverage   95.86%   95.87%           
=======================================
  Files         137      137           
  Lines       13510    13514    +4     
  Branches     2262     2259    -3     
=======================================
+ Hits        12952    12956    +4     
  Misses        558      558           

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

@EdamAme-x
Copy link
Contributor Author

EdamAme-x commented Jul 11, 2024

hi @yusukebe
this pr contains the following two changes.

1. Not includes never

This issue is involved only when the middleware is chained by .use.
When we mark * with middleware, the Schema value contains never.

{
  "*": never
} & {...}

This will also be suggested by hono client as a route.
This is a serious UX concern.


However, this PR does not solve the problem of overriding the handler's schema in the middleware path when defining middleware and handler in the same path.
https://stackblitz.com/edit/hono-client-typing-issue-middleware-s95kgm?file=src%2Fapp.ts

Instead of using & when creating Schema, I can suggest creating and using the type mergeSchema.
I have already built this type.
About this, I'll create a new issue after this pr will be merged.


2. Change Generics of createHandler/createMiddleware

Previously, Path was marked as any by default, so if you did not explicitly mark Path as any, it was marked as never when any was on Schema.

So I marked it at string
It is working now.

image

Since this generics has virtually no effect on the schema, such a change is possible. Anyway, it works as long as it is not any.

@EdamAme-x EdamAme-x changed the title fix(client/factory): not includes never and change generics fix(client): not includes never and change generics Jul 11, 2024
@EdamAme-x EdamAme-x marked this pull request as ready for review July 11, 2024 02:15
@EdamAme-x
Copy link
Contributor Author

Maybe the two changes should be in different PRs.
If desired I will do so.

@EdamAme-x EdamAme-x changed the title fix(client): not includes never and change generics fix(client): not includes never and generics default Path marked at "" Jul 11, 2024
@EdamAme-x EdamAme-x changed the title fix(client): not includes never and generics default Path marked at "" fix(client): not includes never and generics default Path marked at string Jul 11, 2024
@EdamAme-x
Copy link
Contributor Author

EdamAme-x commented Jul 11, 2024

hi @yusukebe
This PR was half resolved by #3128
but I think "1" is not resolved
("*" is suggested by the typescript)

@EdamAme-x EdamAme-x changed the title fix(client): not includes never and generics default Path marked at string fix(client): do not suggest unneccensary route path Jul 11, 2024
@EdamAme-x EdamAme-x changed the title fix(client): do not suggest unneccensary route path fix(client): do not suggest unnecenssary route path Jul 11, 2024
@yusukebe
Copy link
Member

@EdamAme-x

That is another issue.

@yusukebe yusukebe closed this Jul 11, 2024
@EdamAme-x
Copy link
Contributor Author

ok @yusukebe
I'll create new issue

@EdamAme-x EdamAme-x deleted the fix-middleware branch July 11, 2024 09:28
@yusukebe
Copy link
Member

@EdamAme-x

Don't do that. I'll do it.

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.4.12 breaks client typing when using use with a path
2 participants