Repository navigation
feat: types for h5p-verify, h5p-normalize and h5p-embed, and the player's under nodenext - #66
Merged
Merged
Conversation
…h5p-embed The three command packages document a JavaScript API that docs/compatibility.md covers, and shipped no declarations: a TypeScript caller got `any`, or TS7016 under strict. - checkJs over each package's sources, and the 176 errors it found fixed in JSDoc (verify 75, embed 95, normalize 6): types only, but for one condition made explicit in verify's contentChanges and a JSDoc comment the normalizer had above the wrong function. - Declarations generated from the JSDoc at pack time and in typecheck (`pnpm types`, into types/, not in git), named by a `types` condition on each exports entry. Generated, not hand-written: the player's one hand-written .d.mts drifted. - Only the documented API: the helpers each entry exports for its tests are @internal and stripped. Every top-level @typedef is exported, so the types only the code needs stay inline or local. - VerifyReport types report.json field by field; the error, state and refreshed libraries come from the player's own types. startEmbed's pack and runtime are the element's property types. - tests/package-types.ts in each imports the package by its name and is type-checked; it cannot pass without the generated declarations. Closes #60. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… NodeNext resolution - Updated import statements across multiple files to include `.js` extensions, ensuring compatibility with NodeNext module resolution. - Added `tests/package-types.ts` to verify the package's TypeScript declarations as seen by a caller under NodeNext. - Modified `tsconfig.consumer.json` to configure TypeScript for consumer testing, ensuring strict type checking without skipping library checks.
feat: types for the JavaScript APIs of h5p-verify, h5p-normalize and h5p-embed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #60.
#65 was stacked on #61 and merged into #61's branch,
fix/pack-refresh-hash-and-inputs, an hour after #61 itself had gone intomain. GitHub did not retarget it, because the branch was still there. This PR brings the two commits #65 added on top of that branch tomain:node16andnodenext, added to feat: types for the JavaScript APIs of h5p-verify, h5p-normalize and h5p-embed #65 after its last review.The first is described in full in #65. Below is the second.
The player's declarations under
nodenextThe problem. The player's
types/imported its sibling files without an extension ('./shared/protocol').tsccopies an import specifier into the declarations as written.node16andnodenextresolution only follow a relative import that names its file.anywithskipLibCheck, and an error without it. That includesPlayerErrorDetail['code'],missingLibrariesandReadyDetail['source'].bundlerresolution, everything was typed.The fix. The player's relative imports now name their file (
'./shared/protocol.js'), as cmi5's already do.sync-h5p-assetswrites into the generatedpack-index.ts../x.jsto thex.tsbeside it, so the bundles are the same code:h5p-sw.js,h5p-sw-mount.jsh5p-player.js,h5p-jobs.jsThe short names moved because esbuild picks them by character frequency in the source, and the added
.jsstrings shift it.The check.
tests/package-types.tsimports the player by its own name and is compiled bytsconfig.consumer.json, now part of the player'spnpm typecheck.nodenextwithskipLibCheckoff, so a declaration that imports something a caller can't resolve is an error.skipDefaultLibCheckis on, because the DOM and WebWorker libs clash when checked together.@ts-expect-error, which go missing if those types becomeany.tsconfig.test.json, where the source'sH5PPlayerElementwould meet the declarations' one.Testing
arethetypeswrong 0.18.5 on the packed player:
.jsnode16, ESM callerbundlerThe rest of its output is the same before and after:
./swdoesn't resolve undernode10, which reads noexports, and CommonJS callers can only use a dynamic import, as with any ESM-only package.pnpm typecheckpasses across the repo, andpnpm test:unitpasses in every package.pnpm testpassed everything except one verifier test, "fails a package without its libraries". It hung past its 120 s bound in that run and passed when run alone, in 5 s. The player it drives is the same code before and after, so this change isn't the cause. CI here runs it again.Release
main.🤖 Generated with Claude Code