Skip to content

Commit 8118eb2

Browse files
committed
feat: add typescript definitions
1 parent 8dd7a43 commit 8118eb2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

index.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
declare module 'navaid' {
2+
type Promisable<T> = T | Promise<T>;
3+
4+
export type Params = Record<string, string>;
5+
export type UnknownHandler = (uri: string) => void;
6+
export type RouteHandler<T=Params> = (params?: T) => Promisable<any>;
7+
8+
export interface Router {
9+
format(uri: string): string | false;
10+
route(uri: string, replace?: boolean): void;
11+
on<T=Params>(pattern: string, handler: RouteHandler<T>): Router;
12+
run(uri?: string): Router;
13+
listen(uri?: string): Router;
14+
unlisten?: VoidFunction;
15+
}
16+
17+
export default function (base?: string, on404?: UnknownHandler): Router;
18+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"unpkg": "dist/navaid.min.js",
77
"module": "dist/navaid.mjs",
88
"main": "dist/navaid.js",
9+
"types": "index.d.ts",
910
"license": "MIT",
1011
"author": {
1112
"name": "Luke Edwards",
@@ -21,6 +22,7 @@
2122
"test": "uvu -r esm test"
2223
},
2324
"files": [
25+
"*.d.ts",
2426
"dist"
2527
],
2628
"keywords": [

0 commit comments

Comments
 (0)