forked from antfu-collective/vitesse-nuxt3
-
Notifications
You must be signed in to change notification settings - Fork 2
/
typed-router.d.ts
101 lines (92 loc) 路 2.6 KB
/
typed-router.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* ---------------------
* 馃殫馃殾 Generated by nuxt-typed-router. Do not modify !
* ---------------------
* */
import type {
NavigationFailure,
RouteLocation,
RouteLocationNormalizedLoaded,
RouteLocationOptions,
RouteQueryAndHash,
} from 'vue-router'
import type { TypedRouteList } from './__routes'
export type RouteListDecl = { all: 'all'; hiId: 'hi-id'; index: 'index' }
export type TypedRouteParams = {
all: {
all: string | number
}
'hi-id': {
id: string | number
}
index: never
}
type TypedRouteParamsStructure = {
[K in TypedRouteList]: Record<string, string | number> | never
}
type TypedLocationAsRelativeRaw<T extends TypedRouteList> = {
name?: T
params?: TypedRouteParams[T]
}
type TypedRouteLocationRaw<T extends TypedRouteList> = RouteQueryAndHash &
TypedLocationAsRelativeRaw<T> &
RouteLocationOptions
export interface TypedRouter {
/**
* Remove an existing route by its name.
*
* @param name - Name of the route to remove
*/
removeRoute(name: TypedRouteList): void
/**
* Checks if a route with a given name exists
*
* @param name - Name of the route to check
*/
hasRoute(name: TypedRouteList): boolean
/**
* Returns the {@link RouteLocation | normalized version} of a
* {@link RouteLocationRaw | route location}. Also includes an `href` property
* that includes any existing `base`. By default the `currentLocation` used is
* `route.currentRoute` and should only be overriden in advanced use cases.
*
* @param to - Raw route location to resolve
* @param currentLocation - Optional current location to resolve against
*/
resolve<T extends TypedRouteList>(
to: TypedRouteLocationRaw<T>,
currentLocation?: RouteLocationNormalizedLoaded,
): RouteLocation & {
href: string
}
/**
* Programmatically navigate to a new URL by pushing an entry in the history
* stack.
*
* @param to - Route location to navigate to
*/
push<T extends TypedRouteList>(
to: TypedRouteLocationRaw<T>,
): Promise<NavigationFailure | void | undefined>
/**
* Programmatically navigate to a new URL by replacing the current entry in
* the history stack.
*
* @param to - Route location to navigate to
*/
replace<T extends TypedRouteList>(
to: TypedRouteLocationRaw<T>,
): Promise<NavigationFailure | void | undefined>
}
declare module 'nuxt/dist/app/nuxt' {
export interface NuxtApp {
$typedRouter: TypedRouter
$routesList: RouteListDecl
}
}
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$typedRouter: TypedRouter
$routesList: RouteListDecl
}
}