Skip to content

Return the runtime's TypeScript modules to JSDoc, so an edit reaches pages and tests without a build - #4780

Merged
max-sixty merged 2 commits into
mainfrom
review-js-ts
Oct 30, 2026
Merged

max-sixty merged 2 commits into
mainfrom
review-js-ts

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

#4725 to #4757 wrote seven runtime modules in TypeScript (semantic-state, rendering, queued-work, exception and the framework's application, presentation and snapshot) and committed a generated .js beside each. Pages and runtime tests read only the generated file. The kernel's freshness check hashes .js files, and tests/runtime/dom.mjs resolves the committed .js. So an edit to a .ts changed nothing until pnpm run build:browser ran, and every probe and test passed on the old code. That is the failure #4112 described and #4184 fixed. The conversion bought no stricter checking, since the same strict program checks JSDoc under // @ts-check, and the files came out about the same length.

The seven modules are authored JavaScript again. Each starts with // @ts-check in the strict program and keeps every flag the campaign added (strictFunctionTypes, noImplicitThis, useUnknownInCatchVariables). The executable code is unchanged: run through esbuild and compared as ASTs, each new module matches the generated file it replaces, and the kernel diff is only variable renames and input hashes.

After appending an export to semantic-state What a page server serves Has the edit
main, editing semantic-state.ts the same kernel, still taken as fresh no
this branch, editing semantic-state.js the source modules yes

With the framework's application module made to throw as it loads, framework-application.test.mjs passes on main (55 of 55, since it imports the generated file) and fails on this branch.

What it deletes

  • build/runtime-sources.mjs, the compile and orphan-cleanup logic in build/browser/build.mjs, and its tests.
  • The generated-output handling in .github/scripts/dependency-bundles.mjs, .dependency-cruiser.mjs, tests/js_facts.mjs and tests/journeys/test_unused_exports.py.
  • The checker-derived options Type and normalize runtime failure boundaries #4739 gave build/esbuild.mjs, which only the TypeScript emission needed. It returns to tsconfigRaw: "{}".

The build now refuses any .ts other than .d.ts under browser/runtime/, naming the file and #4112. The pragma guard is back to #4184's form, covering framework modules only. browser/AGENTS.md again describes the runtime as JavaScript a page runs as written.

Other changes

  • Export audit. The converted modules take their types through JSDoc @import tags. tests/js_facts.mjs now reads those as it reads import("…").Name; without that, the audit reported LocalMessage and PendingProjection in domain.d.ts as unread. dev/tests/test_js_facts.py replaces its tests of the output mapping with tests of the tag.
  • Dev probes. This removes Check developer browser probes and add focused correctness lints #4743's type-checking of the four dev probes (main_thread.js, startup.js, bench_latency.js, verify_site_browser.js) and dev/browser-globals.d.ts. It found nothing, and a mistake there fails as soon as the probe runs. Check developer browser probes and add focused correctness lints #4743's five ESLint rules stay.
  • Spawn forwarder. The forwarder in dev/leaf_dev/pi_watch_observer.mjs returns to its three-argument form. Check JavaScript tooling against dependency APIs #4737's tools program rejects that form's arity against spawn's overloads, so one @type cast wraps it in place of Reflect.apply and two casts.

Tests

  • pnpm run check:hooks, check:tools, check:framework (29 build tests) and check:browser after merging main.
  • pnpm run check, run before these last edits: 708 runtime and 88 Worker tests.
  • uv run pytest tests/model -k "kernel or runtime_selection or distribution or js_facts" (19 passed) and dev/tests/test_js_facts.py (6 passed).
  • Pre-commit on every changed file.

Build tests that changed: the test that a renamed TypeScript owner's output is refused is gone with the mechanism. New tests cover the .ts refusal and the framework pragma guard.

tests/journeys/test_unused_exports.py still fails on six exports, each in a file this change doesn't touch and no removed .ts file read: check-api.js runtimeRootState, content-layout.js readDocumentHeaders, framework.js Directive, widget-elements.js selectableOfferElement, toc-view.js outlineDocument, and layout.js containedSpace. This PR's edit to the test makes CI run it.

This was written by Claude Code on behalf of max-sixty

…pages and tests without a build

#4725 to #4757 wrote seven runtime modules in TypeScript and committed a
generated .js beside each. Pages and runtime tests read only the generated
file, so an edit to a .ts changed nothing until pnpm run build:browser ran,
and every probe and test passed on the old code: the failure #4112
described and #4184 fixed. The conversion bought no stricter checking,
since the same strict program checks JSDoc under // @ts-check, and about
the same length.

The seven modules are authored JavaScript again, each starting with
// @ts-check in the strict program, with the same executable code. The
build refuses a .ts under browser/runtime/ and names #4112. This deletes
the compile and orphan-cleanup mechanism (build/runtime-sources.mjs) and
the checker-derived esbuild options only it needed. The export audit
(tests/js_facts.mjs) now reads JSDoc @import tags.

Also removes #4743's type-checking of the dev probes, keeping its five
lint rules, and returns #4737's spawn forwarder to its three-argument form.
@max-sixty
max-sixty merged commit 0b220dd into main Oct 30, 2026
3 of 4 checks passed
@max-sixty
max-sixty deleted the review-js-ts branch October 30, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants