Skip to content

Commit a947aa7

Browse files
committed
feat: add types
1 parent 3b591e5 commit a947aa7

File tree

6 files changed

+4104
-3
lines changed

6 files changed

+4104
-3
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
- name: Lint code
3232
run: npm run lint
3333

34+
- name: Check types
35+
run: npm run test-types
36+
3437
test:
3538
name: Test - Node.js ${{ matrix.node-version }}
3639
runs-on: ubuntu-latest

index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference types="node" />
2+
3+
import { IncomingMessage, ServerResponse } from "node:http";
4+
5+
declare function finalhandler(
6+
req: IncomingMessage,
7+
res: ServerResponse,
8+
options?: finalhandler.Options
9+
): (err?: any) => void;
10+
11+
declare namespace finalhandler {
12+
interface Options {
13+
env?: string | undefined;
14+
onerror?:
15+
| ((err: any, req: IncomingMessage, res: ServerResponse) => void)
16+
| undefined;
17+
}
18+
}
19+
20+
export = finalhandler;

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"author": "Douglas Christopher Wilson <[email protected]>",
66
"license": "MIT",
77
"repository": "pillarjs/finalhandler",
8+
"type": "commonjs",
9+
"main": "index.js",
10+
"types": "types/index.d.ts",
811
"dependencies": {
912
"debug": "^4.4.0",
1013
"encodeurl": "^2.0.0",
@@ -14,21 +17,27 @@
1417
"statuses": "^2.0.1"
1518
},
1619
"devDependencies": {
20+
"@arethetypeswrong/cli": "^0.17.4",
21+
"@tsconfig/node18": "^18.2.4",
22+
"@types/node": "^22.13.10",
1723
"eslint": "7.32.0",
1824
"eslint-config-standard": "14.1.1",
1925
"eslint-plugin-import": "2.26.0",
2026
"eslint-plugin-markdown": "2.2.1",
2127
"eslint-plugin-node": "11.1.0",
2228
"eslint-plugin-promise": "5.2.0",
2329
"eslint-plugin-standard": "4.1.0",
30+
"expect-type": "^1.2.0",
2431
"mocha": "^11.0.1",
2532
"nyc": "^17.1.0",
26-
"supertest": "^7.0.0"
33+
"supertest": "^7.0.0",
34+
"typescript": "^5.8.2"
2735
},
2836
"files": [
2937
"LICENSE",
3038
"HISTORY.md",
31-
"index.js"
39+
"index.js",
40+
"index.d.ts"
3241
],
3342
"engines": {
3443
"node": ">= 0.8"
@@ -38,6 +47,7 @@
3847
"test": "mocha --reporter spec --check-leaks test/",
3948
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
4049
"test-cov": "nyc --reporter=html --reporter=text npm test",
41-
"test-inspect": "mocha --reporter spec --inspect --inspect-brk test/"
50+
"test-inspect": "mocha --reporter spec --inspect --inspect-brk test/",
51+
"test-types": "tsc --noEmit && attw --pack"
4252
}
4353
}

0 commit comments

Comments
 (0)