-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroutes.d.ts
More file actions
75 lines (75 loc) · 1.8 KB
/
routes.d.ts
File metadata and controls
75 lines (75 loc) · 1.8 KB
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
import { ComponentType } from 'react';
export declare class Redirect {
location: Location;
constructor(location: Location);
}
export declare type Routing = (location: {
path?: string;
args?: Params;
name?: string;
}, redirect: (location: Location) => Redirect) => Promise<RouteProps | Redirect | undefined>;
export declare type Component<T> = ComponentType<T> & {
routing?: Routing;
};
export declare type ImportComponent = () => Promise<Component<any>>;
export declare type RouteNode = {
name?: string;
path?: string;
directory?: string;
component?: string;
ssr?: boolean;
_path?: string;
_params?: string[];
importComponent?: ImportComponent;
children?: RouteNode[];
};
export declare type RouteNames = {
[key: string]: {
pathTemplate: string;
paramsRegex: {
[key: string]: string;
};
paramsOptional: {
[key: string]: boolean;
};
};
};
export declare type RouteData = {
data: RouteNode;
notFound: Location;
names?: RouteNames;
};
export declare type MatchedRoute = [
{
path: string;
importComponent: ImportComponent;
}[],
Params,
string?
];
export declare type Params = {
[key: string]: string;
};
export declare type RouteProps = {
[key: string]: any;
};
export interface LoadedRoute {
route: {
path: string;
component: Component<any>;
props: RouteProps;
}[];
location: Location;
}
export interface Location {
name?: string;
path?: string;
args?: Params;
}
export interface Routes {
data: RouteData;
match(target: string): Promise<LoadedRoute>;
check(target: string): boolean;
link(location: Location): string;
}
export default function routes({ data, names, notFound }: RouteData): Routes;