Skip to content

Commit c297f39

Browse files
committed
docs: simplify RouterLink usage
1 parent f2b2ef6 commit c297f39

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

packages/docs/guide/advanced/typed-routes.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# Typed routes (v4.1.0+)
1+
# Typed Routes (v4.1.0+)
22

3-
> ⚠️ This feature is still experimental and will evolve in the future
3+
::: danger
4+
5+
⚠️ This feature is still experimental and will evolve in the future, make sure to follow along in release notes and check the [Troubleshooting](#troubleshooting) section if you have issues.
6+
7+
:::
48

59
With typed routes you get type validation when calling `router.push()` as well as autocompletion for the route path. It gives you:
610

@@ -41,23 +45,7 @@ declare module 'vue-router' {
4145

4246
### Typed `<RouterLink>`
4347

44-
It's also possible to type the `to` prop of `<RouterLink>` by overriding the global type used by Vue. You can add this in the `router.ts` file, right after the previous snippet of code:
45-
46-
```ts{1,9-13}
47-
import type { RouterLinkTyped } from 'vue-router'
48-
49-
export const router = createRouter({
50-
// ...options
51-
})
52-
53-
// other code
54-
55-
declare module 'vue' {
56-
interface GlobalComponents {
57-
RouterLink: RouterLinkTyped<typeof router>
58-
}
59-
}
60-
```
48+
Providing the router instance to the `Config` interface above, will also provide typings to the `<RouterLink>` component's `to` prop.
6149

6250
## Caveats
6351

@@ -67,4 +55,4 @@ If you have [dynamic routes](../advanced/dynamic-routing.md), these cannot be ty
6755

6856
## Troubleshooting
6957

70-
If you ever find something blocking you or making your types too slow, you can just remove the `as const` part to rollback to the previous version of the types. If something not mentioned here isn't working and you think it sohuld be working, please open an issue on [GitHub](https://github.com/vuejs/router/issues).
58+
If you ever find something blocking you or making your types too slow, you can just remove the `as const` part to rollback to the previous version of the types. If something not mentioned here isn't working and you think it should be working, please open an issue on [GitHub](https://github.com/vuejs/router/issues).

0 commit comments

Comments
 (0)