feat(types): make Hono client's $url return the exact URL type
Summary
This pull request enhances the type safety and expressiveness of the client-side URL generation in the Hono framework. The main improvement is the introduction of a new TypedURL type, which allows the client to generate URLs with strongly-typed protocol, host, port, path, and query parameters based on the application's route schema and the provided base URL. Several generics and utility types are introduced to propagate this type information throughout the client, ensuring that URL generation is accurate and type-checked at compile time.
esbuild v0.15.18 doesn't support const type parameters, so I updated esbuild.
Motivation
I wanted to add types so that keys used with SWR would be easy to reuse in other parts of the codebase. However, $url did not preserve that type information, so I created this PR.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 91.55%. Comparing base (6efc564) to head (d322285).
Additional details and impacted files
@@ Coverage Diff @@
## next #4502 +/- ##
=======================================
Coverage 91.55% 91.55%
=======================================
Files 172 172
Lines 11225 11225
Branches 3261 3261
=======================================
Hits 10277 10277
Misses 947 947
Partials 1 1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Hi @miyaji255
This is super interesting. I'll look at it deeply later.
Sorry for being late. Anyway, this change is not a "fix", but a "feat". It's a new feature.
@miyaji255
This is awesome! We can include this feature in the next minor release. So, I'll merge when preparing to release it. Thank you!