Skip to content

Commit

Permalink
feat: type generation script
Browse files Browse the repository at this point in the history
  • Loading branch information
tor0405 committed Dec 18, 2023
1 parent 10eacc1 commit 8662636
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
12 changes: 12 additions & 0 deletions fixup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

## Append the following to types/layout.d.ts
cat >> types/layout.d.ts <<!EOF
declare global {
namespace Express {
interface Response {
podiumSend(fragment: string, ...args: unknown[]): Response;
}
}
}
!EOF
2 changes: 2 additions & 0 deletions lib/layout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-nocheck

/* eslint-disable consistent-return */
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-restricted-syntax */
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
"lib"
],
"main": "./lib/layout.js",
"types": "layout.d.ts",
"types": "./types/layout.d.ts",
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "tap --disable-coverage --allow-empty-coverage",
"test:snapshots": "tap --snapshot --disable-coverage --allow-empty-coverage"
"test:snapshots": "tap --snapshot --disable-coverage --allow-empty-coverage",
"types": "tsc --declaration --emitDeclarationOnly && ./fixup.sh"
},
"dependencies": {
"@metrics/client": "2.5.2",
Expand Down
17 changes: 17 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"lib": ["es2020"],
"module": "nodenext",
"target": "es2020",
"resolveJsonModule": true,
"checkJs": true,
"allowJs": true,
"moduleResolution": "nodenext",
"declaration": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"outDir": "types"
},
"include": ["./lib/**/*.js"],
"exclude": ["./lib/**/*.test.js"]
}

0 comments on commit 8662636

Please sign in to comment.