-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat: add children route names generic to generated RouteNamedMap
and adjust docs and tests
#602
Open
Anoesj
wants to merge
1
commit into
posva:main
Choose a base branch
from
Anoesj:feat/add-child-route-names-in-generated-dts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,7 @@ | |
"vitest": "vitest --typecheck", | ||
"docs": "vitepress dev docs", | ||
"docs:build": "vitepress build docs", | ||
"docs:preview": "vitepress preview docs", | ||
"lint": "prettier -c '{src,test,e2e,examples,playground}/**/*.{ts,vue}'", | ||
"play": "npm -C playground run dev", | ||
"play:build": "npm -C playground run build", | ||
|
@@ -198,5 +199,17 @@ | |
"vuefire": "^3.2.1", | ||
"webpack": "^5.97.1", | ||
"yorkie": "^2.0.0" | ||
}, | ||
"pnpm": { | ||
"onlyBuiltDependencies": [ | ||
"@parcel/watcher", | ||
"esbuild", | ||
"protobufjs", | ||
"vue-demi", | ||
"yorkie" | ||
], | ||
"patchedDependencies": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This temporary patch needs to be removed before merging. |
||
"vue-router": "patches/vue-router.patch" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
diff --git a/dist/vue-router.d.ts b/dist/vue-router.d.ts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This temporary patch needs to be removed before merging. |
||
index 8f2c2e5a39d50cf517b4aa512d363f402ce2255a..0c9864363cae71d34327a78025629d34240e38e7 100644 | ||
--- a/dist/vue-router.d.ts | ||
+++ b/dist/vue-router.d.ts | ||
@@ -871,6 +871,22 @@ export declare type RouteMap = TypesConfig extends Record<'RouteNamedMap', infer | ||
*/ | ||
export declare type RouteMapGeneric = Record<string | symbol, RouteRecordInfo>; | ||
|
||
+/** | ||
+ * Returns a union of route names from children of the route with given route name | ||
+ */ | ||
+export type GetDeepChildrenRouteNames<T extends keyof RouteMap> = | ||
+ RouteMap[T] extends RouteRecordInfo<any, any, any, any, any, infer N> | ||
+ ? N extends any | ||
+ ? N | GetDeepChildrenRouteNames<N> | ||
+ : never | ||
+ : never | ||
+ | ||
+/** | ||
+ * Returns a union of given route name and the route names of children of that route | ||
+ */ | ||
+export type RouteNameWithChildren<T extends keyof RouteMap> = | ||
+ RouteMapGeneric extends RouteMap ? T : T | GetDeepChildrenRouteNames<T> | ||
+ | ||
/** | ||
* Interface to type `meta` fields in route records. | ||
* | ||
@@ -1148,7 +1164,14 @@ export declare interface _RouteRecordBase extends PathParserOptions { | ||
* Helper type to define a Typed `RouteRecord` | ||
* @see {@link RouteRecord} | ||
*/ | ||
-export declare interface RouteRecordInfo<Name extends string | symbol = string, Path extends string = string, ParamsRaw extends RouteParamsRawGeneric = RouteParamsRawGeneric, Params extends RouteParamsGeneric = RouteParamsGeneric, Meta extends RouteMeta = RouteMeta> { | ||
+export declare interface RouteRecordInfo< | ||
+ Name extends string | symbol = string, | ||
+ Path extends string = string, | ||
+ ParamsRaw extends RouteParamsRawGeneric = RouteParamsRawGeneric, | ||
+ Params extends RouteParamsGeneric = RouteParamsGeneric, | ||
+ Meta extends RouteMeta = RouteMeta, | ||
+ _ChildrenRouteNames extends string | symbol = never, | ||
+> { | ||
name: Name; | ||
path: Path; | ||
paramsRaw: ParamsRaw; | ||
@@ -1740,11 +1763,14 @@ export declare interface UseLinkReturn<Name extends keyof RouteMap = keyof Route | ||
navigate(e?: MouseEvent): Promise<void | NavigationFailure>; | ||
} | ||
|
||
-/** | ||
+type GetRouteLocationNormalizedLoaded<Name extends keyof RouteMap> = | ||
+ Name extends any ? RouteLocationNormalizedLoaded<Name> : never; | ||
+ | ||
+/** | ||
* Returns the current route location. Equivalent to using `$route` inside | ||
* templates. | ||
*/ | ||
-export declare function useRoute<Name extends keyof RouteMap = keyof RouteMap>(_name?: Name): RouteLocationNormalizedLoaded<Name>; | ||
+export declare function useRoute<CurrentRouteName extends keyof RouteMap = keyof RouteMap>(_currentRouteName?: CurrentRouteName): GetRouteLocationNormalizedLoaded<RouteNameWithChildren<CurrentRouteName>>; | ||
|
||
/** | ||
* Returns the router instance. Equivalent to using `$router` inside | ||
diff --git a/dist/vue-router.mjs b/dist/vue-router.mjs | ||
index 399f57cd8150fe8bb96686110b859d7745e5fc8d..b5fbc8ecf857a5b0ce9dda54c323e59785700766 100644 | ||
--- a/dist/vue-router.mjs | ||
+++ b/dist/vue-router.mjs | ||
@@ -3774,7 +3774,7 @@ function useRouter() { | ||
* Returns the current route location. Equivalent to using `$route` inside | ||
* templates. | ||
*/ | ||
-function useRoute(_name) { | ||
+function useRoute(_currentRouteName) { | ||
return inject(routeLocationKey); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not sure if this should be in this PR. With pnpm v10, builds have to be approved. After you do, pnpm adds "approved builds" to
package.json
.