Skip to content

Type-check gts in the editor with TypeScript 7 - #2255

Draft
NullVoxPopuli-ai-agent wants to merge 14 commits into
mainfrom
nvp/ts7-editor
Draft

NullVoxPopuli-ai-agent wants to merge 14 commits into
mainfrom
nvp/ts7-editor

Conversation

@NullVoxPopuli-ai-agent

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Builds on #2254. When the format is gts, the editor starts a worker that runs TypeScript 7 (compiled to wasm) as a language server and shows its diagnostics inline. The template errors map back to the gts source through ember-content-mapper, which runs inside the same worker.

How it fits together:

  • The checker reads the REPL's own file system. node-fs.js next to the worker serves that storage the way Go's wasm runtime reads files: links followed, read-only, with an overlay for what only the checker sees (the tsconfig, and the open document ahead of the compile). repl-sdk only gained the storage reads it needed: readBytes, stat, and entries. The project root is /, and the document is /src/index.gts, the same file the compiler writes.
  • The type packages (ember-source, @glimmer/component, @glint/template, @glint/ember-tsc, ember-content-mapper) are ordinary installs. The client puts them in storage through installer.ensure at the app's own versions, which the vite plugin passes in as a define. A package that is already linked keeps its link, so a snippet's unversioned imports and the checker agree on what a name means. The content mapper reads the installed versions from storage.
  • app/templates/edit/editor/typescript/ holds the worker, the browser build of ember-content-mapper's request handlers, and the CodeMirror client. The client attaches through a compartment in the codemirror modifier, so switching away from gts removes it.
  • config/vite-ts7.mjs builds the worker as its own bundle. Vite's worker support runs the app's close hooks for the worker bundle, which broke the SSG step.
  • File diagnostics are pulled with textDocument/diagnostic through a lint source. TypeScript 7 only pushes project diagnostics, and @codemirror/lsp-client only listens for pushes.
  • The worker answers the server's client/registerCapability and workspace/configuration requests itself, because the CodeMirror client rejects them and that aborted the server's initialization.
  • Storage caches directory handles. A project load reads several hundred declaration files, and every step of a path walk was a round trip.

Costs on the first gts document: the wasm is 48 MB, shipped with the app in three parts under 25 MiB (Cloudflare Pages caps one asset at that size) and about 11 MB over the wire once compressed, plus the type packages from npm, which stay in storage across visits. The worker bundle is 390 KB. Nothing loads for other formats. On a warm visit, diagnostics appear about 5 seconds after the page loads, of which the project load is about 2 seconds.

Limits in this version: gjs is not wired up yet. Packages a snippet installs after the checker started are not seen until the page reloads, because the client does not send file watch notifications.

Merge order

Stacked on #2276 (the repl-sdk storage reads this needs) and #2254 (the wasm package, whose build script builds the wasm in CI). The base is #2276's branch, so #2254's two commits show here until it merges. Merge #2276 and #2254 in either order, then this.

Verified locally with the wasm built from the workspace package: the full Chrome suite passes, repl-sdk's node and browser suites pass, and lint and the type checks pass.

🤖 Generated with Claude Code

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@socket-security

socket-security Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​codemirror/​lsp-client@​6.3.0941009289100

View full report

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Project Preview URL1 Manage
Limber https://nvp-ts7-editor.limber-glimdown.pages.dev on Cloudflare
Tutorial https://nvp-ts7-editor.limber-glimmer-tutorial.pages.dev on Cloudflare

Logs

Footnotes

  1. if these branch preview links are not working, please check the logs for the commit-based preview link. There is a character limit of 28 for the branch subdomain, as well as some other heuristics, described here for the sake of implementation ease in deploy-preview.yml, that algo has been omitted. The URLs are logged in the wrangler output, but it's hard to get outputs from a matrix job. ↩

NullVoxPopuli and others added 14 commits September 18, 2026 16:39
TypeScript 7 compiled for Go's js/wasm target, so that its language
server can run in a browser worker. The wasm is built at publish time
from a pinned commit on a fork that adds a JavaScript spawn bridge for
content mappers. wasm_exec.js is Go's runtime shim, vendored as is.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pnpm turbo build runs it in CI and before publish, and GitHub's runners
have Go, so no workflow needs a Go setup step.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
When the format is gts, the editor starts a worker that runs TypeScript 7
compiled to wasm as a language server, with ember-content-mapper hosted
in the same worker for the gts transform. The editor gets the language
server plugin from @codemirror/lsp-client, plus a lint source that pulls
file diagnostics, because the server only pushes project diagnostics.

The wasm comes from esm.sh via @nullvoxpopuli/tsc-wasm. The type
declarations for the virtual project are collected from node_modules at
build time into ts7-types.json, so they always match the app's
ember-source and Glint versions.

The worker is built as its own bundle by the vite plugin. Vite's own
worker support runs the app's close hooks for the worker bundle, which
made the SSG plugin look for index.html before it existed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The vite plugin copies tsc.wasm from @nullvoxpopuli/tsc-wasm into dist
in parts under 25 MiB, because Cloudflare Pages caps one asset at that
size, and writes a manifest next to them. The worker fetches the parts
in parallel and joins them before compiling. The esm.sh URL, the
version define, and the test-time override are gone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The worker had its own in-memory file system, filled from a JSON of
declaration files that the vite plugin collected at build time. The REPL
already has a file system, with the packages a snippet imports installed
under `/node_modules`, and the checker can read that one.

repl-sdk grows `nodeFs(storage)`: the storage, served the way Go's wasm
runtime reads files. Links are followed, an overlay holds what only the
checker sees (the tsconfig, and the open document ahead of the compile),
and it is read-only because the fs worker is the writer.

The type packages become ordinary installs. The client puts them in
storage through `installer.ensure` at the app's own versions, and links
them when nothing is linked yet, so a snippet's unversioned imports and
the checker agree on what `ember-source` means. The content mapper reads
the versions from the same place.

Storage now caches directory handles. A project load reads several
hundred declaration files, and every step of a path walk was a round
trip. The first diagnostics went from about 4 seconds to about 2 after
the worker starts. The LSP client's request timeout goes up to cover
that first load.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Only the worker serves Go's `globalThis.fs`, so the adapter lives next
to it instead of in repl-sdk. repl-sdk keeps the storage reads it needed
(`readBytes`, `stat`, `entries`), which describe storage, not Go.

Its tests move with it and run in Chrome against the real origin private
file system, the same one the worker reads.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Without `experimentalDecorators`, TypeScript treats `@tracked` as a
standard decorator and hands it a context object its signature does not
accept, which reported TS1240 on every tracked property.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
TypeScript fences the signatures in its hover and completion
documentation as `typescript`. The client only highlights a fence whose
language is the editor's own, so the signatures rendered as plain text.
The client now gets the JavaScript and TypeScript languages for those
fences, and the colors come from the editor's highlight style.

The theme gives the documentation a code background, the editor's
monospace font, and paragraph spacing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The CodeMirror LSP client rendered Markdown with its own copy of
marked, synchronously, and highlighted code fences with the editor's
grammar only. The app already has remark, rehype, and Shiki in a
worker for its documents.

A pnpm patch gives the client a `renderMarkdown` option that may be
asynchronous. Hover content is rendered before the tooltip is created,
completion documentation resolves through the autocompletion info
promise, and signature documentation lands when it is ready. marked is
gone from the client and from the bundle.

The app renders the Markdown with remark-parse, remark-rehype, the
Shiki worker plugin, and rehype-stringify. Raw HTML is dropped on the
way, because the text comes from the type declarations of packages.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The REPL already has an md compiler, configured by the app with its
remark and rehype plugins and the Shiki worker. The documentation from
the language server goes through it now, as `documentation.md`, and
the tooltip takes the rendered HTML. No second Markdown pipeline.

The client needs the compiler for that, so the editor modifier passes
the compiler service's compiler along. The HTML is sanitized with
DOMPurify on the way in, because the text comes from the type
declarations of packages.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The md compiler puts its HTML in a template literal and escaped only
backticks. A document with `${title}` in a code block threw "title is
not defined" when its module was evaluated, and a backslash sequence
like `\n` turned into the character it names. Hovering `Component` in
the editor hit this, because its documentation has an example with
`${title} ${lastName}`.

Backslashes, backticks, and `${` are escaped now. A browser test
covers the three, and the editor gets a hover test that goes through
the language server, the md compiler, and the tooltip.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The markdown compiler turned `{{` in code into `\{{` for every
document. Only glimdown needs that, because its HTML becomes a Glimmer
template. An md document showed the backslash, and so did the
documentation in the editor's tooltips.

The parser takes a `glimmer` option now, and glimdown passes it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The tooltip showed paragraphs with no room between them, headings and
lists as plain lines, and grew as tall as the page. The theme gives the
documentation paragraph spacing, headings, bullets, a scrollable
height, and a wider column.

Hovering before the language server was ready showed nothing, and the
hover had to be repeated once it was. Until the server is ready, a
hover now shows where the loading is at, and the mouse position is
kept. When the server arrives, the editor hovers again on its own.

Tests share one page and one language server, so a test can forget the
server and start it afresh.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The compiler knows more than one flavor of hbs and refuses a fence
that does not say which, so documentation with an hbs example did not
render at all. The tooltip's markdown now tags every hbs fence as
Ember's, the way the glimdown format does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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