Added static method and wrapped in module.

Updated to include static Routie methods.
Wrapped types up into a module definition.
This commit is contained in:
Kevin Wilson
2015-05-27 15:00:54 +01:00
parent 70737c2a24
commit f2603afffa
+28 -10
View File
@@ -3,15 +3,33 @@
// Definitions by: Adilson <https://github.com/Adilson>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Route {
constructor(path: string, name: string): Route;
addHandler(fn: Function): void;
removeHandler(fn: Function): void;
run(params: any): void;
match(path: string, params: any): boolean;
toURL(params: any): string;
declare module routie {
interface Route {
constructor(path: string, name: string): Route;
addHandler(fn: Function): void;
removeHandler(fn: Function): void;
run(params: any): void;
match(path: string, params: any): boolean;
toURL(params: any): string;
}
interface Routie extends RoutieStatic {
(path: string): void;
(path: string, fn: Function): void;
(routes: { [key: string]: Function }): void;
}
interface RoutieStatic {
lookup(name: string, fn: Function): string;
remove(path: string, fn: Function): void;
removeAll(): void;
navigate(path: string, options: RouteOptions): void;
noConflict(): Routie;
}
interface RouteOptions {
silent?: boolean;
}
}
declare function routie(path: string): void;
declare function routie(path: string, fn: Function): void;
declare function routie(routes: { [key: string]: Function }): void;
declare var routie: routie.Routie;