From: pikax Date: Fri, 9 Apr 2021 08:19:33 +0000 (+0100) Subject: changes on the location path X-Git-Tag: v4.1.0~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14ddb948e00c87d4c5cfb3ed09cad0f4628a1fff;p=thirdparty%2Fvuejs%2Frouter.git changes on the location path --- 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({