Skip to content

Instantly share code, notes, and snippets.

@JLarky
Created February 16, 2015 23:47
Show Gist options
  • Save JLarky/a57b4bcc2b506eaf3d8a to your computer and use it in GitHub Desktop.
Save JLarky/a57b4bcc2b506eaf3d8a to your computer and use it in GitHub Desktop.
routerecognizer typescrip type definitions (incomplete)
// Type definitions for RouteRecognizer 0.1.4
// Project: https://github.com/tildeio/route-recognizer
declare class RouteRecognizer {
add(routes: Object[], options?: Object): void;
map(callback: RouteRecognizer.Callback): void;
recognize(path: string): RouteRecognizer.Result;
}
declare module RouteRecognizer {
interface Params {
[key: string]: string
}
export interface Result extends Array<Handler> {
queryParams: Params;
}
export interface Handler {
handler: any;
params: Params;
isDynamic: boolean
}
// route-recognizer/dsl.js
interface Callback {
(e: Match): void;
}
export interface Match {
(path: string): Target;
(path: string, e: Callback): Target;
}
export interface Target {
to(handler: string): void;
to(handler: Function): void;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment