Skip to content

Type-check leaf.js and package widgets, and ship no declaration file in pages - #2850

Merged
max-sixty merged 2 commits into
mainfrom
check-js-wider
Oct 14, 2026
Merged

max-sixty merged 2 commits into
mainfrom
check-js-wider

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

pnpm run check:browser now type-checks leaf.js, the kernel's widgets/, and every bundled package's initial.js and widget modules under the same non-strict checkJs program #2803 added for the runtime. Pages no longer carry vendor/browser-runtime.d.ts: the build stops generating it, and a freshly vendored page (leaf page init --package diff --package playwright) has no .d.ts file.

How the framework's types reach the check now

The generated declaration file sat beside vendor/browser-runtime.js so that tsc would prefer it over the compiled, type-blanked facade. Since it lived in the layer's vendor/, leaf page init copied it into every page. Instead:

  • build/browser/tsconfig.json holds one paths map, which tsconfig.runtime.json now extends. It resolves the rooted paths a page serves, including each package's vendor/ and widgets/, and maps /vendor/browser-runtime.js to index.ts.
  • paths applies only to non-relative specifiers, so the 39 runtime modules (and leaf.js) that imported the facade as ../vendor/browser-runtime.js now import /vendor/browser-runtime.js. That was already the convention: four runtime modules used it, and layer_import_map says every layer module names its dependencies by rooted path. The import map, export, kernel bundle and Node test hooks all resolve it already, and a probe of pr-walkthrough boots with no errors.
  • A relative facade import would silently type against the blanked facade, so the runtime's ESLint ownership rule (semanticStoreOwnershipRule) now refuses one, with a test in build/browser/architecture.test.mjs.
  • The build's diagnostic filter drops diagnostics in each package's vendor/ as well as the layer's.

What the wider check found

  • Dead wiring: leaf.js passed foldMarginEntryOptions and unfoldedMarginEntries to createReactionController, which stopped reading them in fix: restore margin folds after reaction choices close #2753; the overlay no longer exports either, so both were always undefined. Removed, with the stale field in tests/runtime/reactions.test.mjs.
  • Wrong declarations, corrected at their owner: claimTraversals declared that a claim receives a string, but it receives the traversal's URL (lf-tabs reads url.hash). readDiffCoordinate now declares the coordinate it returns.
  • lf-trace used peer?.#bookmarks. tsc refuses that as a grammar error (TS18030), which stopped the whole program, so it now reads peer && peer.#bookmarks.
  • Web Awesome's wa-comparison and wa-radio declarations join the program, so offer() and createElement type those controls.

The rest are JSDoc casts and parameter types. I found no behavior bug.

Checks

pnpm run check:framework (browser build check, including both type programs, plus 110 Node tests) and pnpm run test:runtime (470 tests) pass. Focused pytest on test_unused_exports.py, test_interact_document.py, test_interact_layer.py, test_distribution.py and test_module_url_delivery.py passes (440 tests), as does pre-commit, including ESLint over every runtime module. An error injected into a package widget fails check:browser.

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

max-sixty and others added 2 commits October 14, 2026 08:01
…in pages

`check:browser`'s non-strict program now covers `leaf.js`, the kernel's
`widgets/`, and every bundled package's `initial.js` and widget modules,
beside the runtime modules and render checks it already checked.

The framework's types no longer reach the check through a generated
`vendor/browser-runtime.d.ts`, which `leaf page init` copied into every
page's `vendor/`. Instead both programs share one `paths` map in
`build/browser/tsconfig.json` (the runtime program extends it), which
resolves the rooted paths a page serves, including each package's
`vendor/` and `widgets/`, and maps `/vendor/browser-runtime.js` to
`index.ts`. Runtime modules now import the facade by that served path,
as `layer_import_map` already says every layer module names its
dependencies; a relative path would reach the compiled, type-blanked
facade. The build no longer writes the declaration file.

What the wider check found:

- Dead wiring: `leaf.js` passed `foldMarginEntryOptions` and
  `unfoldedMarginEntries` to `createReactionController`, which stopped
  reading them in #2753 (the overlay no longer exports them either).
  Removed, with the stale field in `tests/runtime/reactions.test.mjs`.
- `claimTraversals` declared that a claim receives a string; it receives
  the traversal's `URL`. `readDiffCoordinate` now declares the coordinate
  it returns.
- `lf-trace` used `peer?.#bookmarks`, which tsc refuses as a grammar
  error; it reads `peer && peer.#bookmarks` now.
- Web Awesome's `wa-comparison` and `wa-radio` declarations join the
  program, so `offer` and `createElement` type those controls.

The rest are JSDoc casts and parameter types. No behavior changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The type check maps only the facade's served path to the framework's
source; a relative path reaches the compiled facade, whose types are
blanked, so what a module imported through it went unchecked. The
runtime's ESLint ownership rule now reports one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 6bf8dc7 into main Oct 14, 2026
3 checks passed
@max-sixty
max-sixty deleted the check-js-wider branch October 14, 2026 15:28
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