Skip to content

Commit

Permalink
feat: add typescript definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Oct 6, 2020
1 parent 8dd7a43 commit 8118eb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
declare module 'navaid' {
type Promisable<T> = T | Promise<T>;

export type Params = Record<string, string>;
export type UnknownHandler = (uri: string) => void;
export type RouteHandler<T=Params> = (params?: T) => Promisable<any>;

export interface Router {
format(uri: string): string | false;
route(uri: string, replace?: boolean): void;
on<T=Params>(pattern: string, handler: RouteHandler<T>): Router;
run(uri?: string): Router;
listen(uri?: string): Router;
unlisten?: VoidFunction;
}

export default function (base?: string, on404?: UnknownHandler): Router;
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"unpkg": "dist/navaid.min.js",
"module": "dist/navaid.mjs",
"main": "dist/navaid.js",
"types": "index.d.ts",
"license": "MIT",
"author": {
"name": "Luke Edwards",
Expand All @@ -21,6 +22,7 @@
"test": "uvu -r esm test"
},
"files": [
"*.d.ts",
"dist"
],
"keywords": [
Expand Down

0 comments on commit 8118eb2

Please sign in to comment.