Skip to content

Commit 6d6d454

Browse files
committed
test: add navigation type tests
1 parent 756f40f commit 6d6d454

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test-dts/navigationGuards.test-d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { createRouter, createWebHistory, expectType } from './index'
2+
import { NavigationFailure } from 'dist/vue-router'
3+
4+
const router = createRouter({
5+
history: createWebHistory(),
6+
routes: [],
7+
})
8+
9+
router.beforeEach((to, from) => {
10+
return { path: '/' }
11+
})
12+
13+
router.beforeEach((to, from) => {
14+
return '/'
15+
})
16+
17+
router.beforeEach((to, from) => {
18+
return false
19+
})
20+
21+
// @ts-expect-error
22+
router.beforeEach((to, from, next) => {
23+
return Symbol('not supported')
24+
})
25+
// @ts-expect-error
26+
router.beforeEach(() => {
27+
return Symbol('not supported')
28+
})
29+
30+
router.beforeEach((to, from, next) => {
31+
// @ts-expect-error
32+
next(Symbol('not supported'))
33+
})
34+
35+
router.afterEach((to, from, failure) => {
36+
expectType<NavigationFailure | undefined | void>(failure)
37+
})

0 commit comments

Comments
 (0)