Skip to content

Commit cba9650

Browse files
xiaoxiangmoeposva
authored andcommitted
feat: add vue 2.7 types
1 parent 9861c55 commit cba9650

File tree

7 files changed

+431
-25
lines changed

7 files changed

+431
-25
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist
2+
*.ts

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
},
3333
"./composables": {
3434
"import": "./dist/composables.mjs",
35-
"require": "./dist/composables.js"
35+
"require": "./dist/composables.js",
36+
"types": "./types/composables.d.ts"
3637
},
3738
"./dist/*": "./dist/*",
3839
"./types/*": "./types/*",

src/composables/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,9 @@ function throwNoCurrentInstance (method) {
112112
`[vue-router]: Missing current instance. ${method}() must be called inside <script setup> or setup().`
113113
)
114114
}
115+
116+
export { default as default } from '../index'
117+
export { default as RouterLink } from '../components/link'
118+
export { default as RouterView } from '../components/view'
119+
export { NavigationFailureType, isNavigationFailure } from '../util/errors'
120+
export { START as START_LOCATION } from '../util/route'

types/composables.d.ts

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Route, VueRouter, NavigationGuard } from './router'
2+
3+
/**
4+
* Returns the current route location. Equivalent to using `$route` inside templates.
5+
*/
6+
export declare function useRoute(): Route
7+
/**
8+
* Returns the router instance. Equivalent to using `$router` inside templates.
9+
*/
10+
export declare function useRouter(): VueRouter
11+
/**
12+
* Add a navigation guard that triggers whenever the current location is about to be updated. Similar to beforeRouteUpdate but can be used in any component. The guard is removed when the component is unmounted.
13+
*
14+
* @param updateGuard NavigationGuard
15+
*/
16+
export declare function onBeforeRouteUpdate(updateGuard: NavigationGuard): void
17+
/**
18+
* Add a navigation guard that triggers whenever the component for the current location is about to be left. Similar to beforeRouteLeave but can be used in any component. The guard is removed when the component is unmounted.
19+
*
20+
* @param leaveGuard NavigationGuard
21+
*/
22+
export declare function onBeforeRouteLeave(leaveGuard: NavigationGuard): void
23+
24+
export {
25+
type RouterMode,
26+
type RouteMeta,
27+
type RawLocation,
28+
type RedirectOption,
29+
type RouterOptions,
30+
type RouteConfig,
31+
type RouteRecord,
32+
type RouteRecordPublic,
33+
type Location,
34+
type Route,
35+
type NavigationGuard,
36+
type NavigationGuardNext,
37+
type NavigationFailure,
38+
NavigationFailureType,
39+
isNavigationFailure,
40+
START_LOCATION,
41+
type RouterViewProps,
42+
RouterView,
43+
type RouterLinkProps,
44+
type RouterLinkSlotArgument,
45+
RouterLink,
46+
VueRouter as default,
47+
} from './router'

types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { VueRouter } from './router'
33

44
export default VueRouter
55

6-
export {
6+
export type {
77
RouterMode,
88
RouteMeta,
99
RawLocation,

0 commit comments

Comments
 (0)