Skip to content

Commit c0d85da

Browse files
committed
Merge pull request DefinitelyTyped#4465 from kwilson/master
Updated Routie defs to include static methods.
2 parents 8cea0de + fa7330d commit c0d85da

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

routie/routie-tests.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,24 @@ routie("users/12312312");
5454
routie("*", function () {
5555
});
5656

57-
routie("anything");
57+
routie("anything");
58+
59+
// STATIC
60+
61+
// Lookup
62+
var existing = routie.lookup("users/bob", () => {
63+
});
64+
65+
// Remove
66+
routie.remove("users/bob", () => {
67+
});
68+
69+
// RemoveAll
70+
routie.removeAll();
71+
72+
// Navigate
73+
routie.navigate("users/bob");
74+
routie.navigate("users/bob", { silent: true });
75+
76+
// NoConflict
77+
var myRoutie = routie.noConflict();

routie/routie.d.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,33 @@
33
// Definitions by: Adilson <https://github.com/Adilson>
44
// Definitions: https://github.com/borisyankov/DefinitelyTyped
55

6-
interface Route {
7-
constructor(path: string, name: string): Route;
8-
addHandler(fn: Function): void;
9-
removeHandler(fn: Function): void;
10-
run(params: any): void;
11-
match(path: string, params: any): boolean;
12-
toURL(params: any): string;
6+
declare module routie {
7+
interface Route {
8+
constructor(path: string, name: string): Route;
9+
addHandler(fn: Function): void;
10+
removeHandler(fn: Function): void;
11+
run(params: any): void;
12+
match(path: string, params: any): boolean;
13+
toURL(params: any): string;
14+
}
15+
16+
interface Routie extends RoutieStatic {
17+
(path: string): void;
18+
(path: string, fn: Function): void;
19+
(routes: { [key: string]: Function }): void;
20+
}
21+
22+
interface RoutieStatic {
23+
lookup(name: string, fn: Function): string;
24+
remove(path: string, fn: Function): void;
25+
removeAll(): void;
26+
navigate(path: string, options?: RouteOptions): void;
27+
noConflict(): Routie;
28+
}
29+
30+
interface RouteOptions {
31+
silent?: boolean;
32+
}
1333
}
1434

15-
declare function routie(path: string): void;
16-
declare function routie(path: string, fn: Function): void;
17-
declare function routie(routes: { [key: string]: Function }): void;
35+
declare var routie: routie.Routie;

0 commit comments

Comments
 (0)