Skip to content

Commit f645cf0

Browse files
committed
refactor(types): reformat
1 parent 1243e8b commit f645cf0

File tree

4 files changed

+237
-215
lines changed

4 files changed

+237
-215
lines changed

Diff for: types/index.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import "./vue";
2-
import { VueRouter } from "./router";
1+
import './vue'
2+
import { VueRouter } from './router'
33

4-
export default VueRouter;
4+
export default VueRouter
55

66
export {
77
RouterMode,
@@ -13,4 +13,4 @@ export {
1313
Location,
1414
Route,
1515
NavigationGuard
16-
} from "./router";
16+
} from './router'

Diff for: types/router.d.ts

+104-88
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,145 @@
1-
import Vue, { ComponentOptions, PluginFunction, AsyncComponent } from "vue";
1+
import Vue, { ComponentOptions, PluginFunction, AsyncComponent } from 'vue'
22

3-
type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent;
4-
type Dictionary<T> = { [key: string]: T };
5-
type ErrorHandler = (err: Error) => void;
3+
type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent
4+
type Dictionary < T > = { [key: string]: T }
5+
type ErrorHandler = (err: Error) => void
66

7-
export type RouterMode = "hash" | "history" | "abstract";
8-
export type RawLocation = string | Location;
9-
export type RedirectOption = RawLocation | ((to: Route) => RawLocation);
10-
export type NavigationGuard<V extends Vue = Vue> = (
7+
export type RouterMode = 'hash' | 'history' | 'abstract'
8+
export type RawLocation = string | Location
9+
export type RedirectOption = RawLocation | ((to: Route) => RawLocation)
10+
export type NavigationGuard < V extends Vue = Vue > = (
1111
to: Route,
1212
from: Route,
1313
next: (to?: RawLocation | false | ((vm: V) => any) | void) => void
1414
) => any
1515

1616
export declare class VueRouter {
17-
constructor (options?: RouterOptions);
17+
constructor(options?: RouterOptions)
1818

19-
app: Vue;
20-
mode: RouterMode;
21-
currentRoute: Route;
19+
app: Vue
20+
mode: RouterMode
21+
currentRoute: Route
2222

23-
beforeEach (guard: NavigationGuard): Function;
24-
beforeResolve (guard: NavigationGuard): Function;
25-
afterEach (hook: (to: Route, from: Route) => any): Function;
26-
push (location: RawLocation): Promise<Route>;
27-
replace (location: RawLocation): Promise<Route>;
28-
push (location: RawLocation, onComplete?: Function, onAbort?: ErrorHandler): void;
29-
replace (location: RawLocation, onComplete?: Function, onAbort?: ErrorHandler): void;
30-
go (n: number): void;
31-
back (): void;
32-
forward (): void;
33-
getMatchedComponents (to?: RawLocation | Route): Component[];
34-
onReady (cb: Function, errorCb?: ErrorHandler): void;
35-
onError (cb: ErrorHandler): void;
36-
addRoutes (routes: RouteConfig[]): void;
37-
resolve (to: RawLocation, current?: Route, append?: boolean): {
38-
location: Location;
39-
route: Route;
40-
href: string;
23+
beforeEach(guard: NavigationGuard): Function
24+
beforeResolve(guard: NavigationGuard): Function
25+
afterEach(hook: (to: Route, from: Route) => any): Function
26+
push(location: RawLocation): Promise<Route>
27+
replace(location: RawLocation): Promise<Route>
28+
push(
29+
location: RawLocation,
30+
onComplete?: Function,
31+
onAbort?: ErrorHandler
32+
): void
33+
replace(
34+
location: RawLocation,
35+
onComplete?: Function,
36+
onAbort?: ErrorHandler
37+
): void
38+
go(n: number): void
39+
back(): void
40+
forward(): void
41+
getMatchedComponents(to?: RawLocation | Route): Component[]
42+
onReady(cb: Function, errorCb?: ErrorHandler): void
43+
onError(cb: ErrorHandler): void
44+
addRoutes(routes: RouteConfig[]): void
45+
resolve(
46+
to: RawLocation,
47+
current?: Route,
48+
append?: boolean
49+
): {
50+
location: Location
51+
route: Route
52+
href: string
4153
// backwards compat
42-
normalizedTo: Location;
43-
resolved: Route;
44-
};
54+
normalizedTo: Location
55+
resolved: Route
56+
}
4557

46-
static install: PluginFunction<never>;
58+
static install: PluginFunction<never>
4759
}
4860

49-
type Position = { x: number, y: number };
50-
type PositionResult = Position | { selector: string, offset?: Position } | void;
61+
type Position = { x: number; y: number }
62+
type PositionResult = Position | { selector: string; offset?: Position } | void
5163

5264
export interface RouterOptions {
53-
routes?: RouteConfig[];
54-
mode?: RouterMode;
55-
fallback?: boolean;
56-
base?: string;
57-
linkActiveClass?: string;
58-
linkExactActiveClass?: string;
59-
parseQuery?: (query: string) => Object;
60-
stringifyQuery?: (query: Object) => string;
65+
routes?: RouteConfig[]
66+
mode?: RouterMode
67+
fallback?: boolean
68+
base?: string
69+
linkActiveClass?: string
70+
linkExactActiveClass?: string
71+
parseQuery?: (query: string) => Object
72+
stringifyQuery?: (query: Object) => string
6173
scrollBehavior?: (
6274
to: Route,
6375
from: Route,
6476
savedPosition: Position | void
65-
) => PositionResult | Promise<PositionResult>;
77+
) => PositionResult | Promise<PositionResult>
6678
}
6779

68-
type RoutePropsFunction = (route: Route) => Object;
80+
type RoutePropsFunction = (route: Route) => Object
6981

7082
export interface PathToRegexpOptions {
71-
sensitive?: boolean;
72-
strict?: boolean;
73-
end?: boolean;
83+
sensitive?: boolean
84+
strict?: boolean
85+
end?: boolean
7486
}
7587

7688
export interface RouteConfig {
77-
path: string;
78-
name?: string;
79-
component?: Component;
80-
components?: Dictionary<Component>;
81-
redirect?: RedirectOption;
82-
alias?: string | string[];
83-
children?: RouteConfig[];
84-
meta?: any;
85-
beforeEnter?: NavigationGuard;
86-
props?: boolean | Object | RoutePropsFunction;
87-
caseSensitive?: boolean;
88-
pathToRegexpOptions?: PathToRegexpOptions;
89+
path: string
90+
name?: string
91+
component?: Component
92+
components?: Dictionary<Component>
93+
redirect?: RedirectOption
94+
alias?: string | string[]
95+
children?: RouteConfig[]
96+
meta?: any
97+
beforeEnter?: NavigationGuard
98+
props?: boolean | Object | RoutePropsFunction
99+
caseSensitive?: boolean
100+
pathToRegexpOptions?: PathToRegexpOptions
89101
}
90102

91103
export interface RouteRecord {
92-
path: string;
93-
regex: RegExp;
94-
components: Dictionary<Component>;
95-
instances: Dictionary<Vue>;
96-
name?: string;
97-
parent?: RouteRecord;
98-
redirect?: RedirectOption;
99-
matchAs?: string;
100-
meta: any;
104+
path: string
105+
regex: RegExp
106+
components: Dictionary<Component>
107+
instances: Dictionary<Vue>
108+
name?: string
109+
parent?: RouteRecord
110+
redirect?: RedirectOption
111+
matchAs?: string
112+
meta: any
101113
beforeEnter?: (
102114
route: Route,
103115
redirect: (location: RawLocation) => void,
104116
next: () => void
105-
) => any;
106-
props: boolean | Object | RoutePropsFunction | Dictionary<boolean | Object | RoutePropsFunction>;
117+
) => any
118+
props:
119+
| boolean
120+
| Object
121+
| RoutePropsFunction
122+
| Dictionary<boolean | Object | RoutePropsFunction>
107123
}
108124

109125
export interface Location {
110-
name?: string;
111-
path?: string;
112-
hash?: string;
113-
query?: Dictionary<string | (string | null)[] | null | undefined>;
114-
params?: Dictionary<string>;
115-
append?: boolean;
116-
replace?: boolean;
126+
name?: string
127+
path?: string
128+
hash?: string
129+
query?: Dictionary<string | (string | null)[] | null | undefined>
130+
params?: Dictionary<string>
131+
append?: boolean
132+
replace?: boolean
117133
}
118134

119135
export interface Route {
120-
path: string;
121-
name?: string;
122-
hash: string;
123-
query: Dictionary<string | (string | null)[]>;
124-
params: Dictionary<string>;
125-
fullPath: string;
126-
matched: RouteRecord[];
127-
redirectedFrom?: string;
128-
meta?: any;
136+
path: string
137+
name?: string
138+
hash: string
139+
query: Dictionary<string | (string | null)[]>
140+
params: Dictionary<string>
141+
fullPath: string
142+
matched: RouteRecord[]
143+
redirectedFrom?: string
144+
meta?: any
129145
}

0 commit comments

Comments
 (0)