forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue-router.d.ts
91 lines (76 loc) · 2.95 KB
/
vue-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
// Type definitions for vue-router 0.7.10
// Project: https://github.com/vuejs/vue-router
// Definitions by: kaorun343 <https://github.com/kaorun343>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../vue/vue.d.ts" />
declare namespace vuerouter {
interface Transition<RootVueApp, FromParams, FromQuery, ToParams, ToQuery> {
from: $route<RootVueApp, FromParams, FromQuery>;
to: $route<RootVueApp, ToParams, ToQuery>;
next(data?: any): void;
abort(reason?: any): void;
redirect(path: string): void;
}
interface RouterOption {
hashbang?: boolean;
history?: boolean;
abstract?: boolean;
root?: string;
linkActiveClass?: string;
saveScrollPosition?: boolean;
transitionOnLoad?: boolean;
suppressTransitionError?: boolean;
}
interface RouterStatic {
new <RootVueApp>(option?: RouterOption): Router<RootVueApp>;
}
interface RouteMapObject {
component: any;
subRoutes?: { [key: string]: RouteMapObject };
[key: string]: any;
}
interface Router<RootVueApp> {
app: RootVueApp;
mode: string;
start(App: any, el: string | Element): void;
stop(): void;
map(routeMap: { [path: string]: RouteMapObject }): void;
on(path: string, config: Object): void;
go(path: string | Object): void;
replace(path: string): void;
redirect(redirectMap: Object): void;
alias(aliasMap: Object): void;
beforeEach<FP, FQ, TP, TQ>(hook: (transition: Transition<RootVueApp, FP, FQ, TP, TQ>) => any): void;
afterEach<FP, FQ, TP, TQ>(hook: (transition: Transition<RootVueApp, FP, FQ, TP, TQ>) => any): void;
}
interface $route<RootVueApp, Params, Query> {
path: string;
params: Params;
query: Query;
router: Router<RootVueApp>;
matched: string[];
name: string;
[key: string]: any;
}
interface TransitionHook<Root, FP, FQ, TP, TQ> {
data?(transition?: Transition<Root, FP, FQ, TP, TQ>): PromiseLike<any> | void;
activate?(transition?: Transition<Root, FP, FQ, TP, TQ>): PromiseLike<any> | void;
deactivate?(transition?: Transition<Root, FP, FQ, TP, TQ>): PromiseLike<any> | void;
canActivate?(transition?: Transition<Root, FP, FQ, TP, TQ>): PromiseLike<any> | boolean | void;
canDeactivate?(transition?: Transition<Root, FP, FQ, TP, TQ>): PromiseLike<any> | boolean | void;
canReuse?: boolean | ((transition: Transition<Root, FP, FQ, TP, TQ>) => boolean);
}
}
declare namespace vuejs {
interface Vue {
$route?: vuerouter.$route<any, any, any>;
$router?: vuerouter.Router<any>;
}
interface ComponentOption {
route?: vuerouter.TransitionHook<any, any, any, any, any>;
}
}
declare var VueRouter: vuerouter.RouterStatic;
declare module "vue-router" {
export = VueRouter;
}