From f2603afffaabe8c70b95d77961745c29036fe858 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:00:54 +0100 Subject: [PATCH 1/5] Added static method and wrapped in module. Updated to include static Routie methods. Wrapped types up into a module definition. --- routie/routie.d.ts | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/routie/routie.d.ts b/routie/routie.d.ts index 9317904d4..d6e4cd281 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -3,15 +3,33 @@ // Definitions by: 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; \ No newline at end of file +declare var routie: routie.Routie; From 34ef6f1dd3ce8c4ead9c1234ca96f2e582f08160 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:02:08 +0100 Subject: [PATCH 2/5] Added to change log. --- routie/routie.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/routie/routie.d.ts b/routie/routie.d.ts index d6e4cd281..cd3bb09dc 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -1,6 +1,7 @@ // Type definitions for routie 0.3.2 // Project: https://github.com/jgallen23/routie // Definitions by: Adilson +// Definitions by: kwilson // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module routie { From e2e6bdb50df936afdcfd91e2e1bdcdb28f392a11 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:13:48 +0100 Subject: [PATCH 3/5] Added tests for static functions. --- routie/routie-tests.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/routie/routie-tests.ts b/routie/routie-tests.ts index 323142c7e..12ee397c4 100644 --- a/routie/routie-tests.ts +++ b/routie/routie-tests.ts @@ -54,4 +54,24 @@ routie("users/12312312"); routie("*", function () { }); -routie("anything"); \ No newline at end of file +routie("anything"); + +// STATIC + +// Lookup +var existing = routie.lookup("users/bob", () => { +}); + +// Remove +routie.remove("users/bob", () => { +}); + +// RemoveAll +routie.removeAll(); + +// Navigate +routie.navigate("users/bob"); +routie.navigate("users/bob", { silent: true }); + +// NoConflict +var myRoutie = routie.noConflict(); From 45d69d19cbc7beae195cfeb5d4d6c085b9073545 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:14:21 +0100 Subject: [PATCH 4/5] Fixed missing optional flag for navigate options. --- routie/routie.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routie/routie.d.ts b/routie/routie.d.ts index cd3bb09dc..8f32c3d78 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -24,7 +24,7 @@ declare module routie { lookup(name: string, fn: Function): string; remove(path: string, fn: Function): void; removeAll(): void; - navigate(path: string, options: RouteOptions): void; + navigate(path: string, options?: RouteOptions): void; noConflict(): Routie; } From fa7330d6fe18c795891fc8465445662ba5cd9675 Mon Sep 17 00:00:00 2001 From: Kevin Wilson Date: Wed, 27 May 2015 15:16:53 +0100 Subject: [PATCH 5/5] Fixed heading error. --- routie/routie.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/routie/routie.d.ts b/routie/routie.d.ts index 8f32c3d78..79ab2dc8a 100644 --- a/routie/routie.d.ts +++ b/routie/routie.d.ts @@ -1,7 +1,6 @@ // Type definitions for routie 0.3.2 // Project: https://github.com/jgallen23/routie // Definitions by: Adilson -// Definitions by: kwilson // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module routie {