Skip to content

Commit

Permalink
feat(types): improve link and view slots (vuejs#1544)
Browse files Browse the repository at this point in the history
Co-authored-by: Eduardo San Martin Morote <[email protected]>
  • Loading branch information
xiaoxiangmoe and posva authored Sep 2, 2022
1 parent 3fe8f81 commit 4a0cc8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/router/src/RouterLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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[]
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/router/src/RouterView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ export const RouterView = RouterViewImpl as unknown as {
RouterViewProps

$slots: {
default: (arg: {
default?: ({
Component,
route,
}: {
Component: VNode
route: RouteLocationNormalizedLoaded
}) => VNode[]
Expand Down

0 comments on commit 4a0cc8b

Please sign in to comment.