Skip to content

wf check: TypeScript type check in a Worker over an in-memory snapshot (#322) - #330

Merged
AM-L merged 2 commits into
developfrom
322-wf-check
Oct 22, 2026
Merged

AM-L merged 2 commits into
developfrom
322-wf-check

Conversation

@ambroise-leclerc

Copy link
Copy Markdown
Collaborator

Closes #322 (epic #303).

Summary

wf check [--timeout <seconds>] runs a real TypeScript type check in the browser with the typescript the project locks.

  • Supported versions: 5.x and 6.x (>=5.0.0 <7.0.0), tested with 5.9.3 and 6.0.3. Older versions and TypeScript 7 (native, without the JavaScript API) are refused with an explicit message.
  • Two phases in a dedicated Worker (typecheck-worker.mjs):
    1. asynchronous loading of an in-memory snapshot through the page (reads and listings only): lib.*.d.ts of the locked typescript, declarations and package.json of the locked graph, project files covered by tsconfig.json (with extends) or by the manifest entries; bounded to 10,000 files / 64 MiB (50,000 listed entries);
    2. synchronous compilation with a CompilerHost over the snapshot (typecheck-snapshot.mjs): a file absent from it does not exist; a truncated snapshot is reported and fails.
  • Type resolution follows TypeScript (types/typings, types condition of exports, @types/*, moduleResolution), limited to the locked graph without flattening: roots under /project/node_modules, each package at /packages/<id>/node_modules/<name> with its dependencies as siblings; realpath maps to the canonical place.
  • Diagnostics file(line,column): error TScode: message, exit code 1 on errors; noEmit is forced, nothing is written.
  • Termination: same mechanism as wf run (runWorker): Ctrl+C / --timeout terminate a running compilation after the 2 s grace period (codes 130 / 124).
  • Local registry fixture: serves typescript 6.0.3 and 5.9.3 (vendor alias typescript5), a synthetic unsupported 4.9.5, typed packages and scoped @types/* packuments (now supported by the fixture).

Docs: new section in docs/DEVELOPER_ENVIRONMENT.md, CHANGELOG, PROJECT_STATUS, README. The pin in DeveloperReleaseData.hpp stays on the published 0.4.1; bundles.json recomputed.

Tests

Per the maintainer's choice, wf check is tested only in the real browser through wf itself (test/web/developer-specs.mjs, local registry): typescript missing, 4.9.5 refused, correct project accepted with 5.9.3 then 6.0.3, all requests to the local registry only, type error with file/line/column/code, snapshot past its bounds, long check stopped by Ctrl+C (Worker terminated after the grace period, no file written or staged, terminal usable).

  • CEF-off CTest: 270/270
  • CEF (Linux): DeveloperBrowserIntegration, DeveloperEmbedded*, LifeEmbedded* pass
  • Node suite (check, distribution-check, manifest-check, restore-check, scripts-check): 64/64

…napshot [#322]

The locked typescript (5.x or 6.x) compiles synchronously over a bounded
snapshot loaded beforehand: its lib files, the declarations of the locked
graph and the project files that tsconfig.json or the manifest entries
cover. Type resolution follows TypeScript within the locked graph, without
flattening. Diagnostics carry file, line, column and code; nothing is
written. Ctrl+C and the time limit terminate a running compilation after
the grace period of wf run. The local registry fixture serves typescript
5.9.3 and 6.0.3, an unsupported 4.9.5, typed and scoped @types packages.
Copilot AI balanced review requested due to automatic review settings October 22, 2026 19:46
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 382f949d-046e-4eb6-982d-9258735c2e2e
📥 Commits

Reviewing files that changed from the base of the PR and between dd2eaf6 and 62cc5b2.

📒 Files selected for processing: 4
  • docs/DEVELOPER_ENVIRONMENT.md
  • js/developer/environment/bundles.json
  • js/developer/environment/typecheck-snapshot.mjs
  • test/web/developer-specs.mjs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 88dc0045-8b87-4c0d-9dca-50fb733582ef
📥 Commits

Reviewing files that changed from the base of the PR and between 2cb1234 and dd2eaf6.

⛔ Files ignored due to path filters: 1
  • js/developer/vendor/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing: 14
  • README.md
  • docs/CHANGELOG.md
  • docs/DEVELOPER_ENVIRONMENT.md
  • docs/PROJECT_STATUS.md
  • js/developer/environment/bundles.json
  • js/developer/environment/runtime.mjs
  • js/developer/environment/typecheck-snapshot.mjs
  • js/developer/environment/typecheck-worker.mjs
  • js/developer/environment/typecheck.mjs
  • js/developer/tools/build.mjs
  • js/developer/tools/registry-fixture-node.mjs
  • js/developer/tools/registry-fixture.mjs
  • js/developer/vendor/package.json
  • test/web/developer-specs.mjs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

La PR ajoute wf check à l’environnement développeur. La commande utilise le TypeScript verrouillé par le projet, charge un instantané en mémoire dans un Worker et affiche les diagnostics. Les tests couvrent les versions prises en charge, les limites de l’instantané et l’interruption du contrôle.

Changes: Vérification TypeScript

Layer / File(s) Summary
Contrat de la commande et versions TypeScript
js/developer/environment/typecheck.mjs, js/developer/vendor/package.json
La commande accepte TypeScript 5.x et 6.x et valide l’option facultative --timeout. L’hôte limite les opérations aux lectures de fichiers et aux listings. Le fournisseur ajoute TypeScript 6.0.3 et l’alias TypeScript 5.
Chargement et compilation de l’instantané
js/developer/environment/typecheck-snapshot.mjs
Le module charge les bibliothèques TypeScript, les déclarations du graphe verrouillé et les fichiers du projet dans un instantané borné. Il crée un hôte synchrone sans émission de fichiers et retourne les diagnostics formatés.
Exécution dans le Worker et intégration à la commande
js/developer/environment/typecheck-worker.mjs, js/developer/environment/runtime.mjs, js/developer/tools/build.mjs, js/developer/environment/bundles.json
Le Worker charge l’instantané et exécute la compilation. runtime.mjs ajoute wf check à l’aide et à la distribution des commandes. Le build et les empreintes incluent les nouveaux modules.
Fixtures, tests et documentation
js/developer/tools/registry-fixture*.mjs, test/web/developer-specs.mjs, README.md, docs/CHANGELOG.md, docs/DEVELOPER_ENVIRONMENT.md, docs/PROJECT_STATUS.md
Les fixtures ajoutent des paquets typés et la prise en charge des noms scoped. Les tests vérifient les versions, les diagnostics, les limites et l’annulation. La documentation décrit la commande et ses contraintes.

Priority: ⚪ Pending latest changes

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Runtime
  participant typecheck-worker
  participant checkHost
  participant loadSnapshot
  participant checkProgram
  Runtime->>typecheck-worker: Lance le contrôle avec le projet verrouillé
  typecheck-worker->>checkHost: Demande des lectures et des listings
  checkHost-->>typecheck-worker: Retourne les données du projet
  typecheck-worker->>loadSnapshot: Charge les déclarations et les fichiers du projet
  loadSnapshot-->>typecheck-worker: Retourne l’instantané
  typecheck-worker->>checkProgram: Compile sans émission
  checkProgram-->>typecheck-worker: Retourne les diagnostics
  typecheck-worker-->>Runtime: Retourne le code de sortie
Loading

Possibly related issues

Merge Risk: ⚪ Minimal · up to dd2ea

No merge-blocking issue was established for wf check; it is ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 8 files. (6 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed Le titre décrit précisément l’ajout principal : wf check effectue une vérification TypeScript dans un Worker sur un instantané en mémoire.
Description check Passed La description est directement liée aux changements. Elle détaille la commande, les versions TypeScript prises en charge, l’instantané, les diagnostics, l’interruption, les tests et la documentation.
Linked Issues check Passed Pour l’objectif de #322, le résumé du PR décrit wf check dans un Worker dédié, avec chargement asynchrone puis compilation synchrone via CompilerHost. Le contrôle utilise la version TypeScript ver…
Out of Scope Changes check Passed Les changements restent liés à #322. Le runtime et les modules de typecheck ajoutent la commande et son exécution. Les tests et la fixture du registre vérifient les critères d’acceptation. Les mises à…
Full details: Linked Issues check

Explanation

Pour l’objectif de #322, le résumé du PR décrit wf check dans un Worker dédié, avec chargement asynchrone puis compilation synchrone via CompilerHost. Le contrôle utilise la version TypeScript verrouillée, limite la résolution au graphe verrouillé, applique les bornes de l’instantané et refuse les versions non prises en charge. Il force noEmit, formate les diagnostics avec fichier, ligne, colonne et code, et gère Ctrl+C ainsi que --timeout. Les tests navigateur décrits couvrent l’erreur de type, la réussite avec types et @types, le registre local, la version 4.9.5, les limites de l’instantané et l’annulation.

Full details: Out of Scope Changes check

Explanation

Les changements restent liés à #322. Le runtime et les modules de typecheck ajoutent la commande et son exécution. Les tests et la fixture du registre vérifient les critères d’acceptation. Les mises à jour de documentation, de l’archive, du build et des empreintes prennent en charge la distribution de cette fonctionnalité. Aucun changement indépendant n’est établi par le résumé du PR.

Full details: Docstring Coverage

Explanation

Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 8 files. (6 skipped: 6 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ite under noEmit [#322]

NodeNext takes a file's module format from the nearest package.json, which
may lie above the directories tsconfig.json includes. Forcing composite off
dropped the declaration it implies and reported TS5069 for valid
configurations; only noEmit is forced now, the host still writes nothing.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It adds a large, intricate TypeScript CompilerHost/module-resolution implementation whose correctness depends on subtle TS-internal behavior and is validated only through browser integration tests, warranting human review.

1 open issue
What changed in this PR

This PR implements wf check, a real TypeScript type check that runs in the browser inside a dedicated Worker, using the typescript version the project locks (5.x/6.x). It fits into the developer-environment epic (#303) as the type-checking counterpart to the esbuild previews, which strip types without checking them. The check runs in two phases: an asynchronous pass loads an in-memory snapshot (lib files, locked-graph declarations, project files covered by tsconfig.json or manifest entries, within bounds), then a synchronous CompilerHost compiles over that snapshot with TypeScript's own module resolution. Termination reuses the wf run Worker mechanism (Ctrl+C / --timeout, grace period, exit codes 130/124).

Changes:

  • New environment modules typecheck.mjs (page side / version gating), typecheck-worker.mjs (Worker driver), and typecheck-snapshot.mjs (snapshot, layout, CompilerHost, diagnostics), wired into runtime.mjs as the check command.
  • Registry fixture now supports scoped packages and serves typed/@types packages plus typescript 5.9.3/6.0.3 and a synthetic unsupported 4.9.5; vendor package.json/lock add typescript and the typescript5 alias.
  • Build/bundle plumbing (build.mjs, bundles.json) adds the new worker entry; docs (README, DEVELOPER_ENVIRONMENT, PROJECT_STATUS, CHANGELOG) and the browser integration test cover the feature.
File Description
js/​developer/​environment/​typecheck-snapshot.mjs New: in-memory snapshot, locked-graph layout, CompilerHost, diagnostics/report.
js/​developer/​environment/​typecheck-worker.mjs New: Worker that loads TS, runs phase 1 (async) then phase 2 (sync).
js/​developer/​environment/​typecheck.mjs New: version gating and page-side read/list host for the check.
js/​developer/​environment/​runtime.mjs Adds the check command, help text, and Worker factory.
js/​developer/​tools/​registry-fixture.mjs Adds scoped-package support and typed/@types/old-typescript fixtures.
js/​developer/​tools/​registry-fixture-node.mjs Creates parent directories for scoped packument files.
js/​developer/​tools/​build.mjs Bundles/ships typecheck-worker.mjs; tracks new inputs.
js/​developer/​environment/​bundles.json Updated source hashes for the new/changed modules.
js/​developer/​vendor/​package.json, package-lock.json Add typescript 6.0.3 and typescript5 (typescript@5.9.3).
test/​web/​developer-specs.mjs Browser integration coverage for wf check.
README.md, docs/​*.md Document wf check, versions, bounds, and behavior.

Review effort: Balanced

Comment on lines +298 to +311
} else {
const converted = ts.convertCompilerOptionsFromJson(defaultCompilerOptions, projectRoot);
options = converted.options;
errors = converted.errors;
const sources = entries.filter(entry => projectExtensions(options).some(extension => entry.endsWith(extension)));
if (!sources.length)
throw new Error('wf check needs a tsconfig.json or TypeScript entries in webfront.project.json');
// The directories of the entries, recursively: the files they import are found there.
const directories = [...new Set(sources.map(entry => entry.includes('/') ? entry.slice(0, entry.lastIndexOf('/')) : ''))];
const listed = await listProject(snapshot, list, directories.map(directory => [directory, true]), bounds, signal);
for (const path of new Set([...sources, ...listed.filter(projectSource(options))]))
await loadProjectFile(path);
rootNames = sources.map(entry => `${projectRoot}/${entry}`);
}
@AM-L
AM-L merged commit 523d28b into develop Oct 22, 2026
14 checks passed
@AM-L
AM-L deleted the 322-wf-check branch October 22, 2026 20:35
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.

wf check : adaptateur TypeScript (CompilerHost) pour un typecheck dans le navigateur

3 participants