]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
changes on the location path
authorpikax <carlos@hypermob.co.uk>
Fri, 9 Apr 2021 08:19:33 +0000 (09:19 +0100)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Thu, 30 Jun 2022 07:59:00 +0000 (09:59 +0200)
src/types/index.ts
test-dts/namedRoutes.test-d.ts

index 438b524f61bbad01e6e0cfd02451495c033ac69d..6d313ab238c5af54297d8303f953111e58884b6c 100644 (file)
@@ -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<RouteRecordRaw[]>
   /**
    * 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
index 8ecc91bac1542b5a085bfc7c99ebf78a5ed66826..ffe62f106afe07d1e173c50dd967b544e83ec5f1 100644 (file)
@@ -30,13 +30,22 @@ const routes = [
 type TypedRoutes = ExtractNamedRoutes<typeof routes>
 
 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({