fix(mcp, verify): a type check writes the declarations it reads first

Merged
AL
3d ago
+12-3

Closes #261.

What changes

  • mcp's typecheck runs pnpm --filter @missing-elements/h5p-verify --filter @missing-elements/h5p-author run types before tsc -p tsconfig.json. Without verify's types/, TypeScript checked verify.mjs itself under mcp's Node-only lib and failed on window and document. That stopped mcp 0.4.0's publish (run 44726189991), where verify was not being released and so nothing wrote its types.
  • verify's types builds the player's declarations first (tsc -b in packages/player), as the author's types always has. Alone, from a checkout with no types/, verify's own typecheck failed the same way.
  • design/build.md: a fourth rule under the declarations: a package's typecheck writes the declarations it reads first, and passes alone.

Checked

With every types/ folder and every build-info file deleted before each run:

  • each package's typecheck alone: mcp, verify, author, embed, cmi5, normalize, player, runtime, vscode, all pass;
  • before the fix, mcp failed with the 22 errors of the publish run, and verify with 1;
  • pnpm -r typecheck passes;
  • mcp's tests: 21. verify still packs (its prepack runs types).

After merging

Run publish.yml again. It skips normalize 1.5.0 and author 0.15.0, which are on npm, and publishes h5p-mcp 0.4.0. Its version needs no bump: 0.4.0 never reached npm.


Summary by cubic

Fixes #261: each package's typecheck now writes the declarations it reads first, so it passes alone from a clean checkout with no types/ folders.

  • mcp's typecheck runs verify's and author's types before tsc. Without verify's declarations, TypeScript fell back to verify.mjs under mcp's Node-only lib and failed on window and document, stopping the mcp 0.4.0 publish when verify wasn't released.
  • verify's types now builds the player's declarations first (tsc -b in packages/player), as author's already did.
  • design/build.md documents the rule that a typecheck writes what it reads.
  • Publish should be run again to release h5p-mcp 0.4.0, which never reached npm.