]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat(types): improve link and view slots (#1544)
authorZHAO Jinxiang <xiaoxiangmoe@gmail.com>
Fri, 2 Sep 2022 12:39:51 +0000 (05:39 -0700)
committerGitHub <noreply@github.com>
Fri, 2 Sep 2022 12:39:51 +0000 (14:39 +0200)
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
packages/router/src/RouterLink.ts
packages/router/src/RouterView.ts

index 3bc133dafaa30ca635c83a8910979f88db35d0cf..1d18845d670e3e6696ee28c1e49f145181fd1781 100644 (file)
@@ -174,6 +174,9 @@ export function useLink(props: UseLinkOptions) {
     }
   }
 
+  /**
+   * NOTE: update {@link _RouterLinkI}'s `$slots` type when updating this
+   */
   return {
     route,
     href: computed(() => route.value.href),
@@ -269,7 +272,13 @@ export interface _RouterLinkI {
       RouterLinkProps
 
     $slots: {
-      default: (arg: UnwrapRef<ReturnType<typeof useLink>>) => VNode[]
+      default?: ({
+        route,
+        href,
+        isActive,
+        isExactActive,
+        navigate,
+      }: UnwrapRef<ReturnType<typeof useLink>>) => VNode[]
     }
   }
 
index ad136f60218213ffad5f828e871fa4d6540eb959..4ad60d038665def58d8a077662372fc6369f340d 100644 (file)
@@ -224,7 +224,10 @@ export const RouterView = RouterViewImpl as unknown as {
       RouterViewProps
 
     $slots: {
-      default: (arg: {
+      default?: ({
+        Component,
+        route,
+      }: {
         Component: VNode
         route: RouteLocationNormalizedLoaded
       }) => VNode[]