Skip to content

Commit

Permalink
fix(link): fix slot types
Browse files Browse the repository at this point in the history
Fix #27
  • Loading branch information
posva committed Jul 7, 2022
1 parent ce8ac78 commit 64ff5b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { useLink, useRoute } from '@vue-router'
import type { RouteNamedMap } from '@vue-router/routes'
import type { RouteLocationNormalizedLoaded } from '@vue-router'
const route = useRoute()
if (route.name === '/deep/nesting/works/[[files]]+') {
Expand Down Expand Up @@ -32,8 +33,8 @@ const customRoute = useRoute('/deep/nesting/works/custom-path')
>
<button @click="$router.push('/oeu')">Click</button>
{{ $route.name === '' }}
<RouterLink to="/:name" v-slot="{ name }">
{{ name }}
<RouterLink to="/:name" v-slot="{ route }">
{{ (route as RouteLocationNormalizedLoaded<'/[name]'>).params.name }}
</RouterLink>
</nav>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/typeExtensions/RouterLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
VNodeProps,
VNode,
ComputedRef,
UnwrapRef,
} from 'vue'
import type {
NavigationFailure,
Expand Down Expand Up @@ -48,7 +49,7 @@ export interface RouterLinkTyped<RouteMap extends _RouteMapGeneric> {

$slots: {
// TODO: is it correct to use the resolve tip?
default: (arg: ReturnType<_RouterTyped<RouteMap>['resolve']>) => VNode[]
default: (arg: UnwrapRef<_UseLinkReturnTyped<RouteMap>>) => VNode[]
}
}
}
Expand Down

0 comments on commit 64ff5b6

Please sign in to comment.