From 14ddb948e00c87d4c5cfb3ed09cad0f4628a1fff Mon Sep 17 00:00:00 2001 From: pikax Date: Fri, 9 Apr 2021 09:19:33 +0100 Subject: [PATCH] changes on the location path --- src/types/index.ts | 12 +++++++++--- test-dts/namedRoutes.test-d.ts | 11 ++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/types/index.ts b/src/types/index.ts index 438b524f..6d313ab2 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -72,9 +72,11 @@ export interface LocationAsName { /** * @internal */ -export interface LocationAsRelativeRaw { - name?: {} extends NamedLocationMap ? RouteRecordName : keyof NamedLocationMap - params?: RouteParamsRaw +export interface LocationAsRelativeRaw< + T extends keyof NamedLocationMap = keyof NamedLocationMap +> { + name?: {} extends NamedLocationMap ? RouteRecordName : T + params?: {} extends NamedLocationMap ? RouteParamsRaw : NamedLocationMap[T] } export interface LocationAsRelative { @@ -218,6 +220,10 @@ export interface _RouteRecordBase extends PathParserOptions { */ redirect?: RouteRecordRedirectOption + /** + * Array of nested routes. + */ + children?: RouteRecordRaw[] | Readonly /** * Aliases for the record. Allows defining extra paths that will behave like a * copy of the record. Allows having paths shorthands like `/users/:id` and diff --git a/test-dts/namedRoutes.test-d.ts b/test-dts/namedRoutes.test-d.ts index 8ecc91ba..ffe62f10 100644 --- a/test-dts/namedRoutes.test-d.ts +++ b/test-dts/namedRoutes.test-d.ts @@ -30,13 +30,22 @@ const routes = [ type TypedRoutes = ExtractNamedRoutes declare module './index' { - interface NamedLocationMap extends TypedRoutes {} + interface NamedLocationMap { + 'my-other-path': { + sss: number + } + } } declare const router: Router router.push({ name: 'my-other-path', + params: { + sss: 1, + // @ts-expect-error + xxxx: '22', + }, }) router.push({ -- 2.47.3