-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: make typed useRoute(currentRouteName) return children route types as well
#2475
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
Conversation
✅ Deploy Preview for vue-router canceled.
|
Codecov Report
All modified and coverable lines are covered by tests ✅
Project coverage is 94.89%. Comparing base (
3753ede) to head (bc9cea2).
Report is 15 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@ ## main #2475 +/- ## ======================================= Coverage 94.89% 94.89% ======================================= Files 34 34 Lines 2998 2998 Branches 845 845 ======================================= Hits 2845 2845 Misses 150 150 Partials 3 3
☔ 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.
@posva
posva
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ready!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this type param because it was never used and I figured it's safer to add it back later if needed than leaving an unused type param that can eventually be used. I marked this as a fix because the leftover type param should have never been released in the first place
Co-authored-by: Eduardo San Martin Morote <posva13@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
In an app (with a typed router) where route
/a/bis a child of route/a, this makesuseRoute('/a')returnRouteLocationNormalizedLoadedTyped<RouteNamedMap, "/a"> | RouteLocationNormalizedLoadedTyped<RouteNamedMap, "/a/b">.It works in a recursive manner, so whenever route
/a/b/cis added as a child of/a/b,useRoute('/a')will returnRouteLocationNormalizedLoadedTyped<RouteNamedMap, "/a"> | RouteLocationNormalizedLoadedTyped<RouteNamedMap, "/a/b">| RouteLocationNormalizedLoadedTyped<RouteNamedMap, "/a/b/c">`.Of course
useRoute('/a/b/c')will only returnRouteLocationNormalizedLoadedTyped<RouteNamedMap, "/a/b/c">.Note
This PR is intended to be paired with the following
unplugin-vue-routerPR: posva/unplugin-vue-router#602That PR changes the DTS generation to include
RouteMetaand a union of the children route's names as generics to everyRouteRecordInfotype.