Skip to content

Commit 5f0167a

Browse files
committed
Add JSDoc-to-d.ts publishing pipeline
- Add deno task dts (tsc + dts-bundle-generator + fix-phaser-dts) and dts:check - Add mod.d.ts artifact with @ts-self-types pragma in mod.js - Update CI to run dts:check, publish to regenerate before publishing - Reorganize CONTEXT.md by directory hierarchy, document pipeline - Add JSDoc type annotations to PropEngine - Add tsconfig.json, tsconfig.bundle.json, scripts/fix-phaser-dts.ts
1 parent af64ca4 commit 5f0167a

12 files changed

Lines changed: 4529 additions & 108 deletions

File tree

.github/workflows/publish.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ jobs:
1616
- uses: denoland/setup-deno@v2
1717
with:
1818
deno-version: v2.x
19-
- run: deno publish --allow-slow-types
19+
- run: deno task dts # regenerate the bundled mod.d.ts from JSDoc
20+
- run: deno publish

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
.history/
2+
13
node_modules/
24
dist/
5+
types/
6+
37
.DS_Store
4-
.history/

CONTEXT.md

Lines changed: 151 additions & 99 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,25 @@ To work on a game and the engine side by side without publishing, map the packag
8888
## Development
8989

9090
```bash
91-
deno task ci # lint + fmt:check + check + test
91+
deno task ci # lint + fmt:check + check + dts:check + test
9292
deno task test
93+
deno task dts # regenerate the bundled mod.d.ts from JSDoc
9394
```
9495

96+
## Types
97+
98+
The engine is authored in JavaScript with JSDoc. To ship real types (and satisfy JSR fast-check without
99+
`--allow-slow-types`), `deno task dts` compiles the JSDoc to declarations with `tsc`, rolls them into a single
100+
self-contained `mod.d.ts`, and `mod.js` points at it via `// @ts-self-types`. `deno task dts:check` (run in CI)
101+
regenerates it and fails if the committed `mod.d.ts` is stale, so types can never drift from the source.
102+
95103
## Publishing
96104

97105
```bash
98-
deno publish --allow-slow-types
106+
deno task dts && deno publish
99107
```
100108

101-
Requires the `@caper` scope on JSR. The engine is authored in JavaScript with JSDoc types, so JSR ships it with "slow
102-
types" (no generated `.d.ts`); `--allow-slow-types` acknowledges that.
109+
Requires the `@caper` scope on JSR. Pushing a `v*` tag runs this via `.github/workflows/publish.yml`.
103110

104111
## License
105112

deno.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
},
1616
"tasks": {
1717
"check": "deno check mod.js src/",
18+
"types": "deno run -A npm:typescript/bin/tsc -p tsconfig.json",
19+
"dts": "deno task types && deno run -A npm:dts-bundle-generator@9 -o mod.d.ts --project tsconfig.bundle.json --no-check types/mod.d.ts && deno run --allow-read=mod.d.ts --allow-write=mod.d.ts scripts/fix-phaser-dts.ts",
20+
"dts:check": "deno task dts && git diff --exit-code mod.d.ts",
1821
"test": "deno test --permit-no-files --allow-read src/",
1922
"lint": "deno lint",
2023
"fmt": "deno fmt mod.js src/ docs/ README.md deno.json",
2124
"fmt:check": "deno fmt --check mod.js src/ docs/ README.md deno.json",
22-
"ci": "deno task lint && deno task fmt:check && deno task check && deno task test"
25+
"ci": "deno task lint && deno task fmt:check && deno task check && deno task dts:check && deno task test"
2326
},
2427
"imports": {
2528
"@std/assert": "jsr:@std/assert@^1.0.19",
@@ -28,7 +31,8 @@
2831
},
2932
"exclude": [
3033
"node_modules/",
31-
"dist/"
34+
"dist/",
35+
"types/"
3236
],
3337
"fmt": {
3438
"indentWidth": 4,
@@ -37,6 +41,9 @@
3741
"singleQuote": false
3842
},
3943
"lint": {
44+
"exclude": [
45+
"mod.d.ts"
46+
],
4047
"rules": {
4148
"exclude": [
4249
"no-window-prefix",

deno.lock

Lines changed: 95 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)