Skip to content

Commit 643e9ab

Browse files
committed
Merge pull request #225 from tristanlins/feature-ts.d.js
Add typescript declaration file.
2 parents f78c81e + ca51496 commit 643e9ab

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Resources/ts/router.d.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
declare module FOS {
2+
export interface RouteDefaults {
3+
[index:string]:string;
4+
}
5+
6+
export interface RouteRequirements {
7+
[index:string]:string;
8+
}
9+
10+
export interface RouteParams {
11+
[index:string]:any;
12+
}
13+
14+
export interface QueryParamAddFunction {
15+
(prefix:string,params:any):void;
16+
}
17+
18+
export interface Route {
19+
tokens:string[][];
20+
defaults:RouteDefaults;
21+
requirements:RouteRequirements;
22+
hosttokens:string[];
23+
}
24+
25+
export interface RoutesMap {
26+
[index:string]:Route;
27+
}
28+
29+
export interface Context {
30+
base_url:string;
31+
}
32+
33+
export interface Router {
34+
new(opt_context?:Context, opt_routes?:RoutesMap):Router;
35+
setRoutes(routes:RoutesMap):void;
36+
getRoutes():RoutesMap;
37+
setBaseUrl(base_url:string):void;
38+
getBaseUrl():string;
39+
setPrefix(prefix:string):void;
40+
setScheme(scheme:string):void;
41+
getScheme():string;
42+
setHost(host:string):void;
43+
getHost():string;
44+
45+
/**
46+
* Builds query string params added to a URL.
47+
* Port of jQuery's $.param() function, so credit is due there.
48+
*/
49+
buildQueryParams(prefix:string,params:any,add:QueryParamAddFunction):void;
50+
51+
/**
52+
* Returns a raw route object.
53+
*/
54+
getRoute(name:string):Route;
55+
56+
/**
57+
* Generates the URL for a route.
58+
*/
59+
generate(name:string,opt_params?:RouteParams,absolute?:boolean):string;
60+
}
61+
}
62+
63+
declare var Routing:FOS.Router;

0 commit comments

Comments
 (0)