Skip to content

Native TypeScript 7 support for .tsrx through a content mapper (#41) - #135

Merged
leonidaz merged 117 commits into
mainfrom
feat/content-mapper-41
Oct 2, 2026
Merged

leonidaz merged 117 commits into
mainfrom
feat/content-mapper-41

Conversation

@leonidaz

@leonidaz leonidaz commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Implements #41, Phases 0–4, one commit per task, plus the follow-ups of 2026-09-19 listed at the end (the summary below reflects the branch as it stands; earlier states are in the commit history).

Closes #827, closes #829.

Summary

  • @tsrx/content-mapper (new): a TypeScript 7 content mapper so native tsc --runExternalCode and tsc --lsp type-check .tsrx files with the same target-specific type-only transform as tsrx-tsc. Spans are Verbatim / Alias / Atom with feature bits; <script> bodies are blocks inside the generated TSX (no supplemental outputs); every TSRX compile error is a TSRX<code> diagnostic at its authored position, with an ignore directive that hides TypeScript's own copy of the mistake; a file that fails to compile is replaced by an export stub so importers keep resolving. dynamicConfig with a hashed configIdentity and watched files.
  • @tsrx/typescript-plugin: the transform is factored into src/transform.js and shared by every path; <script> bodies are blanked in the JSX text (fixes a TS1003 that the classic path silently dropped when a body contains <) and appended to the generated TSX as block statements with mappings, import declarations of <script type="module"> bodies hoisted to module level, so tsserver, the language server and the mapper all type-check them in place; the tsserver plugin drops TypeScript's diagnostics for a file while it has a fatal TSRX compile error; dead suppressedDiagnostics plumbing removed. tsrx-tsc follows the installed TypeScript: on a 7.1 nightly with the content-mapper protocol it runs the native binary with --runExternalCode and refuses a tsconfig without a .tsrx mapper; a TypeScript 7 build without the protocol is explained.
  • @tsrx/language-server: --typescript-backend=<classic|native|plugin> / typescriptBackend init option. On native the server serves only what TypeScript 7 does not own; plugin is the same slim set plus TSRX compile errors, for editors whose own tsserver serves .tsrx through the plugin; volar-service-typescript is loaded lazily and only on classic; a typescript.tsdk init option names the TypeScript to host on classic. Default stays classic.
  • VS Code: no setting, no bundled TypeScript, no patch of the built-in extension. It activates Microsoft's TypeScript extensions and registers .tsrx through an available content-mapper API, leaving server selection to Microsoft. VS Code's own TypeScript serves .tsrx files: its tsserver through @tsrx/typescript-plugin, contributed via typescriptServerPlugins (with languages: ["tsrx"], so VS Code manages .tsrx documents and its own TypeScript commands and menus work on them) and shipped in the VSIX, or TypeScript 7 through the content mapper declared in tsconfig.json when TypeScript 7 is selected. The TSRX server always runs slim (plugin mode); its compile-error copy is dropped once the mapper has been seen reporting in the session, so compile errors show once either way. Activates on a single .tsrx file; declares untrustedWorkspaces.supported: false.
  • Editor guides for Zed, Neovim (setup(plugin, { typescript_backend })), IntelliJ and Sublime Text.
  • Phase 4 documents in packages/content-mapper/: BENCHMARKS.md (harness bench/bench.js, raw reports under bench/results/), COMPATIBILITY.md (36 classified rows with evidence), ROLLOUT.md (release notes, migration, rollback, default-backend decision).

Native is 2.1–3.6× faster on cold checks, 3.3–4× faster edit-to-diagnostics and uses 25–45% less peak memory than the classic path on the same projects, with one extra Node mapper process per tsc invocation or language-server session.

Default-backend decision (ROLLOUT.md): CLI docs keep tsrx-tsc, which is classic on TypeScript 5.9/6 and native on TypeScript 7; language server defaults to classic for other editors; VS Code has no default to pick, it follows the TypeScript VS Code runs. The classic path stays for as long as TypeScript 5.9/6 are supported; no deprecation is planned. tsrx-tsc works with every supported version, and TypeScript 7 can also run tsc --runExternalCode directly.

Validation

  • pnpm test --project content-mapper --project typescript-plugin --project language-server --project vscode-plugin: 779 tests green
  • pnpm typecheck green (including packages/content-mapper/bench/)
  • pnpm changeset:check green; eleven changesets: minor for @tsrx/typescript-plugin (with its fixed group), @tsrx/language-server and @tsrx/vscode-plugin, patch for @tsrx/core and @tsrx/content-mapper
  • Targets: React, Preact, Solid, Vue fixtures and the external Ripple playground (playground/ripple in the Ripple repo, 1,648-line App.tsrx) report identical diagnostics on both paths; a stub third-party compiler is covered through tsrx.compiler and mapper options
  • TypeScript nightly: the root installs 7.1.0-dev.20260930.4 (catalog:native), and the minimum is 7.1.0-dev.20260923.1; macOS x64 only so far

Follow-ups

Needed before flipping any default (tracked in COMPATIBILITY.md and ROLLOUT.md):

Upstream issues filed (2026-09-19, both verified first: no existing report, no config or mapper-side workaround):

  • Content mappers: composite projects report TS6307 for supplemental virtual outputs microsoft/TypeScript#64350: TS6307 in composite (--build) projects for the compiler-named supplemental <script> output. Reproduced with a 30-line standalone mapper; include globs never match the virtual file, files gives TS6053, and referenced projects must be composite. No longer affects TSRX since 4bb54b2: <script> bodies are blocks in the generated TSX and there is no supplemental output; native-build.test.js now type-checks a <script> body inside a referenced composite library.
  • tsc --watch never recompiles on macOS since 7.1.0-dev.20260811.1 microsoft/TypeScript#64351: --watch never recompiled on macOS. Reproduced on a plain .ts project without a mapper and bisected across the nightlies: last good 7.1.0-dev.20260810.1, first bad 7.1.0-dev.20260811.1 (8 upstream commits in the window). Every --watchFile strategy, directory casing, symlinks and stdin state made no difference, so it is distinct from FSEvents watcher drops events when requested casing differs from disk casing microsoft/TypeScript#64089. Fixed upstream by Fix case sensitivity fswatch and users microsoft/TypeScript#64210 (merged 2026-09-22), first shipped in 7.1.0-dev.20260923.1. Verified on 2026-09-30 with the TSRX mapper: --watch recompiles after both .tsrx and .ts edits on 7.1.0-dev.20260923.1 and 7.1.0-dev.20260930.4, it still never recompiles on 7.1.0-dev.20260922.1, and the whole content-mapper suite passes on both fixed builds. Closed upstream with those results on 2026-09-30.
    • Not a gap: tsc --build --watch recompiles after an edit to a file the tsconfig lists (include globs match .tsrx once the mapper is declared), but not after an edit to a file that is only imported. TypeScript 6.0.3 behaves the same for plain .ts files (a standalone probe with an identity .foo mapper and plain .ts controls). It surfaced only because the consumer fixture lists just main.ts.

Validation gaps (COMPATIBILITY.md, "Not yet exercised"):

  • Resolution: paths aliases, monorepo symlinks beyond the junctioned test workspaces, .tsx importers of .tsrx modules
  • Editors: inlay hints with hints enabled; which formatter VS Code picks for .tsrx now that TypeScript 7 registers textDocument/formatting (it returns no edits; Prettier must keep winning); CSS features in <style> on the native backend in a real editor; third-party compiler fixture under the language server
  • Lifecycle: deleting and renaming .tsrx files during a native session; more than one mapper-backed project in one tsc --build graph
  • Packaging (macOS only): published @tsrx/content-mapper tarball and the VSIX outside the checkout; still open on Linux and Windows (only macOS x64 has been run); CI has no TypeScript 7 platform package for other OSes yet
  • Benchmarks on a second machine and on Linux; the ~600 ms native floor is mapper start-up (Node + compiler load) and is worth profiling

Docs and process:

  • tsrx.dev and website-tsrx/public/llms.txt: document contentMappers, tsc --runExternalCode, the VS Code setting and the per-editor native setup (not touched in this PR)
  • The Ripple repo: adopt contentMappers in playground/ripple/tsconfig.json and exclude debug/ (the stale generated dump there is the only diagnostic on both paths); ship a Ripple-side guide now that @tsrx/content-mapper@0.1.0 is published (2026-09-20)
  • pnpm format:check fails locally only on untracked packages/intellij-plugin/.intellijPlatform/** sandbox files; consider ignoring that directory in .prettierignore

Follow-ups done on 2026-09-19 (commits 2b43b24 … 74e5854)

  • Tracking issue for everything between here and complete TypeScript 7 support: TypeScript 7.x support: tracking upstream blockers and known gaps #136. The VS Code warning, the CLI and language-server messages and the docs point to it and ask for new issues for untracked gaps.
  • Minimum TypeScript for the native path is 7.1.0-dev.20260822.1 (bisected across the nightlies with the new TSRX_NATIVE_TSC override); stable typescript@7.0.2 has no content-mapper protocol (TS5023 for --runExternalCode). No 7.1 beta or RC exists yet.
  • TypeScript 6.0.3 passes the whole classic suite; the typescript peer range is ^5.9.3 || ^6.0.0. tsrx-tsc and the classic language server explain the typescript@7 package (a launcher without a JavaScript API) instead of failing on its export map.
  • The native path needs only TypeScript 7: the plugin reads tsconfig and resolves compiler packages itself (jsonc-parser, get-tsconfig's extends rules, resolve-pkg-maps), the mapper has no typescript dependency and starts ~3× faster, the language server's native backend runs on Volar's plain project host; both are tested with the typescript package forbidden.
  • VS Code: no marketplace release of the TypeScript 7 extension supports content mappers yet (TypeScript 7 TypeScriptTeam.native-preview stopped at 0.20260708.2, before the feature; the TypeScript 7 Nightly extension is compiler-only); until TypeScript 7.1 and its extension ship, it takes a build of packages/vscode-typescript from microsoft/TypeScript (the typescript-go staging repository is closed). Resolved on 2026-09-30: the marketplace TypeScript 7 extension (TypeScriptTeam.native-preview) jumped to 1.0.1. Its VSIX has the registerContentMappers(id, [{ extensions }]) API the TSRX extension probes for (same signature as the source build), plus the js/ts.contentMappers.enabled setting, so a from-source build is no longer needed. Its bundled compiler, though, is tsc 7.0.2, which has no content-mapper protocol. It picks the compiler in this order: a js/ts.tsdk.path setting (a workspace-level one only in a trusted workspace after Use Workspace Version), then the TypeScript 7 Nightly extension (TypeScriptTeam.vscode-typescript-nightly, a 7.1 nightly binary with no code of its own) if installed, then the bundled 7.0.2. So .tsrx files need either the Nightly extension or a workspace typescript 7.1 nightly selected with TypeScript: Select TypeScript Version. Checked in the package; the editor check is in progress.
  • tsrx-tsc runs on TypeScript 7 (aba93df): when the installed typescript is a 7.1 nightly with the content-mapper protocol, the wrapper resolves the launcher's @typescript/typescript-<os>-<arch> package the way lib/getExePath.js does and runs the native binary with --runExternalCode (after the arguments in --build mode, first otherwise), so one package.json script serves TypeScript 5.9, 6 and 7. It reads the tsconfig files the invocation would use through the plugin's own extends-aware reader (in --build mode every compiling project of the references graph, solution configs skipped; a config that does not parse is left to tsc, f49b583) and refuses to run one without a .tsrx content mapper (TypeScript would silently skip those files and importers would get TS2307); contentMappers is not a CLI option and does inherit through extends, both verified against the pinned binary. Stable 7.0 and nightlies before 7.1.0-dev.20260822.1 are still explained. @tsrx/content-mapper is an optional peer of the plugin. Covered by tsc.test.js (stub launcher plus a recording platform binary) and the new tsrx-tsc-native.test.js (end to end on the pinned binary, classic diagnostics required); 423 tests green across content-mapper, typescript-plugin, language-server and vscode-plugin, plus pnpm typecheck, format:check and changeset:check.
  • Ripple: with the stale debug/ dump excluded, the playground shows 30 pre-existing diagnostics on both paths (identical apart from one duplicate-Vite-types TS2320 on native); the exclude is an uncommitted change in the Ripple checkout, and contentMappers can be adopted now that @tsrx/content-mapper@0.1.0 is published (2026-09-20).

Follow-ups done on 2026-09-19, later (commits 6df042f … 4bb54b2)

  • VS Code delegates TypeScript features to Microsoft's extensions without reading selection settings or bundling TypeScript. The tsrx.typescript.backend setting, the tsdk resolution and the runtime patch of the built-in TypeScript extension are gone. Instead the extension contributes @tsrx/typescript-plugin through VS Code's typescriptServerPlugins point (enableForWorkspaceTypeScriptVersions, languages: ["tsrx"]) and ships it in the VSIX, so VS Code's own tsserver serves .tsrx files, whichever TypeScript it runs (its bundled copy or the workspace version), manages .tsrx documents itself, and resolves .tsrx imports from .ts files with no tsconfig plugins entry. With TypeScript 7 selected, TypeScript 7 serves them through the content mapper. The TSRX server always runs in the new slim plugin mode and reports TSRX compile errors; the extension drops that copy once the mapper has been seen reporting in the session. Verified in isolated VS Code 1.138 instances (own user-data and extensions directories, the TypeScript 7 extension built from microsoft/TypeScript with the pinned 7.1 nightly embedded) on VS Code's bundled 6.0.3 with no settings, the workspace 5.9.3 and 6.0.3 versions, and the 7.1 nightly: diagnostics inside .tsrx, TypeScript and CSS-selector hover from one provider, the importer's cross-file error, definition into .tsrx, one TSRX compile error, and a type error inside a <script> body at its source position.
  • <script> bodies are type-checked on every path (4bb54b2): blocks in the generated TSX instead of extra service scripts (which Volar's tsserver-plugin path does not support) and supplemental .mts outputs. This also lifts the composite-project TS6307 limitation and removes the *.tsrx.<n>.d.mts declaration files. Script-body declarations are no longer document symbols on any path.
  • tsrx.typescript.backend and js/ts.experimental.useTsgo are not read any more. The two menu context keys the extension used to set are VS Code's own. (Since 2026-09-30 the extension reads js/ts.experimental.useTsgo again, only to close tags on TypeScript 7 and to say which TypeScript serves .tsrx files; see the last section.)
  • Repository tooling: @typescript/native-preview (the retired preview package) is gone; pnpm typecheck runs the pinned TypeScript 7.1 platform binary through scripts/native-tsc.js (the root typescript launcher when it is TypeScript 7, the pinned binary otherwise); tsdown is on 0.23 with byte-identical bundles.
  • Docs: one rule for tsconfig across the editor READMEs, the plugin README and the site: TypeScript 5.9 or 6 in editors other than VS Code need compilerOptions.plugins with @tsrx/typescript-plugin; VS Code needs nothing; TypeScript 7 needs contentMappers everywhere. The TypeScript 7 extension's one-time warning about the TSRX tsserver plugin is explained as harmless.
  • Fixed along the way: the component-function snippet was listed twice in every completion popup.
  • Observed TypeScript 7 gaps recorded in TypeScript 7.x support: tracking upstream blockers and known gaps #136 for filing upstream: the TypeScript 7 extension warns about every extension that contributes a tsserver plugin with no way to opt out; import code actions on .tsrx files apply no edits.

Error reporting on TypeScript 7 (2026-09-30, commits 14af950 … 95e5614)

Main is merged in (455fc88).

Each mistake shows once. The generated code can lose a mistake the parser records with a TypeScript code, and then TypeScript never reports it:

declare declare class A {}   // source: TS1030 'declare' modifier already seen
declare class A {}           // generated: the tree keeps modifiers as flags

On TypeScript 7, 21 such errors were lost this way: modifier order and repeats, ? on a rest or destructured parameter, the comma after a rest element, a decorator on a function. The mapper now sends every compile error, and for each one an ignore diagnostic directive (the protocol's diagnosticDirectives) over the generated code of the statement, class or type member, or element that holds it. Where TypeScript reports the mistake too, or a follow-on error of a TSRX mistake, its copy stays hidden until the mapper's error is fixed. The ranges come from the compiler's sourceAst and Volar mappings, so every target compiler gets the same, and the mapper README now says what a compiler has to return.

Validation: the content-mapper, typescript-plugin, language-server and vscode-plugin projects (748 tests) and every tsrx-* project (5,647 tests) pass; the typecheck of core, content-mapper, language-server and vscode-plugin is clean, and so are format:check and changeset:check.

VS Code with the marketplace TypeScript 7 extension, closing tags, and the repository on the 7.1 nightly (2026-09-30 to 10-01, commits b445cd6 … a6dd4ef)

Main is merged in (d282f11, which brings #985 for #983).

The TypeScript 7 extension 1.0.1 left .tsrx files with nothing. The marketplace extension supports content mappers, but it runs its built-in tsc 7.0.2, which can't run the mapper, and it finds a workspace compiler only in node_modules/@typescript/native-preview, last published on 2026-07-07 (filed as microsoft/TypeScript#64565). With js/ts.experimental.useTsgo on (the extension turns it on at its first start), VS Code's own TypeScript steps aside, so nothing checked .tsrx files.

Setup (extension README, ROLLOUT.md, website, llms.txt; e664dac). Editor tests show these make the TypeScript 7 extension run the project's 7.1 nightly with nothing to click:

  1. npm install -D typescript@next (until TypeScript 7.1 is released)

  2. In the VS Code user settings:

    {
      "js/ts.experimental.useTsgo": true,
      "js/ts.tsdk.path": "node_modules/typescript"
    }
  3. Install the TypeScript 7 extension.

The relative path resolves per project. A project on TypeScript 5.9, or without typescript, falls back to the built-in 7.0.2, and VS Code's own TypeScript is unaffected when TypeScript 7 is off. The TypeScript 7 Nightly extension isn't needed and is no longer recommended. Making the TypeScript 7 extension a dependency was ruled out: at its first start it turns TypeScript 7 on for everyone, which would break TypeScript 5.9/6 projects. #991 tracks simplifying the steps once microsoft/TypeScript#64565 is fixed and TypeScript 7.1 ships.

Status item and notices (15df53f, e664dac, a3c86f2): a language status item on .tsrx files names the TypeScript that serves them. When a setup leaves .tsrx files unchecked, a notice says what to do, once per window:

TypeScript 7 uses version 7.0.2. This version cannot type-check .tsrx files. Your project has version 7.1.0-dev.20260930.4. To use it, click Use Project TypeScript.

Use Project TypeScript writes the setting: "js/ts.tsdk.path": "node_modules/typescript" in the user settings when the open folder installs the 7.1 nightly (no prompt), or the subfolder's path in the workspace settings when only a subfolder does. The first version opened the setting for the user to type the path; in practice the path went into the Settings search box, and even a saved value did nothing, because the TypeScript 7 extension reads its tsdk settings only when it starts. So the extension now restarts TypeScript 7 whenever a tsdk change alters the compiler it should run: its server for a user setting, the extension host for a workspace setting (only its start-up asks to allow one). Hand edits need no reload either.

A project without 7.1 is told to install typescript@next; a project on 7.1 without the TypeScript 7 extension is offered Install TypeScript 7; TypeScript 7 on with only the Nightly extension (which only adds a compiler) gets Install TypeScript 7 or Turn Off TypeScript 7. Nothing changes or installs unless a button is clicked. The compiler is worked out the way the TypeScript 7 extension does it (src/typescript-7.js).

Closing tags. Typing <b> before </button> in a .tsrx file used to rely on the TSRX language server alone, in every setup. Now TypeScript closes it wherever it can:

TSRX: Restart Language Server (a6dd4ef, closes #829): the Command Palette had no way to restart the TSRX server. The command restarts it together with the TypeScript server that serves .tsrx files: VS Code's tsserver with TypeScript 7 off, TypeScript 7 with it on. The README has a Restarting section.

Editor tests in real VS Code (pnpm --filter @tsrx/vscode-plugin test:editor): each scenario starts an isolated VS Code (its own user data and extensions directories) on a fixture project. It checks hover, go-to-definition, a type error in the unsaved buffer, closing a typed <b>, the TypeScript status, and the notices; two click a notice button and two run the restart command. On macOS the windows stay out of the way (9865741): VS Code brings its first window to the front even when started hidden, so a small Swift helper hides it the moment macOS reports it active (about 0.1 s per scenario, measured). All 19 scenarios pass:

Scenario Setup Served by After typing <b> Notice
ts7-recommended the README setup, project on the 7.1 nightly TypeScript 7 (7.1.0-dev.20260930.4) <b></b> none
ts7-recommended-tsrx-closing-off same, TSRX closing off TypeScript 7 <b> (#64564) none
ts7-recommended-restart the README setup, then TSRX: Restart Language Server TypeScript 7 again afterwards <b></b> none
ts7-recommended-no-project-typescript the README settings, no typescript in the project nothing (built-in 7.0.2) <b></b> install typescript@next
ts7-recommended-classic-project the README settings, project on TypeScript 5.9 nothing (built-in 7.0.2) <b></b> install typescript@next
ts7-bundled TypeScript 7 on, no js/ts.tsdk.path, project on 7.1 nothing (built-in 7.0.2) <b></b> set js/ts.tsdk.path
ts7-bundled-use-project-typescript same, click Use Project TypeScript TypeScript 7 (the project's 7.1) afterwards, no reload <b></b> —
ts7-bundled-turn-off same, click Turn Off TypeScript 7 VS Code TypeScript afterwards, no reload <b></b> —
ts7-first-run TypeScript 7 extension, no settings (turns itself on) nothing (built-in 7.0.2) <b></b> install typescript@next
ts7-nightly-extension TypeScript 7 + Nightly extensions TypeScript 7 (Nightly's 7.1) <b></b> none
ts7-nightly-only only the Nightly extension, TypeScript 7 on nothing <b></b> install TypeScript 7
ts7-off TypeScript 7 extension, off VS Code TypeScript <b></b> none
vscode-typescript TSRX only VS Code TypeScript <b></b> none
vscode-typescript-restart TSRX only, then TSRX: Restart Language Server VS Code TypeScript again afterwards <b></b> none
vscode-typescript-tsrx-closing-off TSRX closing off VS Code TypeScript <b></b> (TypeScript closes it) none
vscode-typescript-closing-off VS Code TypeScript closing off VS Code TypeScript <b> none
vscode-typescript-project-ts7 TSRX only, project on 7.1 VS Code TypeScript <b></b> install TypeScript 7
vscode-typescript-tsdk-ts7-project TSRX only, js/ts.tsdk.path set, project on 7.1 VS Code TypeScript <b></b> install TypeScript 7
vscode-typescript-tsdk-classic-project TSRX only, js/ts.tsdk.path set, project on 5.9 VS Code TypeScript <b></b> none

Repository on the TypeScript 7.1 nightly.

  • The root installs typescript@7.1.0-dev.20260930.4 (catalog:native) and pnpm typecheck runs its tsc (b445cd6). The Hono tests and the playgrounds are type-checked with tsc --runExternalCode and contentMappers instead of tsrx-tsc (b1f96e2).
  • The minimum TypeScript 7 build is now 7.1.0-dev.20260923.1, the first nightly whose tsc --watch recompiles (b77d26b), and the typescript peer range admits it: ^5.9.3 || ^6.0.0 || ^7.1.0-dev.20260923.1 (8527a06).
  • pnpm --filter @tsrx/vscode-plugin build builds the workspace packages the extension ships before bundling, so build-and-package never packs stale dist/ folders (b790693).
  • Native TypeScript 7 support for .tsrx through a content mapper (#41) #135 was the document of record for TypeScript 7 status (1da058c) until TypeScript 7.x support: tracking upstream blockers and known gaps #136 was reopened as the tracking issue on 2026-10-01; the messages and docs link there again (d242a16). tsc --build --watch missing edits to unlisted files is not a gap: TypeScript 6 behaves the same (2dde250).

Bugbot: an error's ignore directive spanned from the first to the last generated code of the element holding it. A <script> body is checked at the end of the file, so the range covered every component in between and hid their TypeScript errors. Each piece of the element's generated code now gets its own range (5c7e52c).

Validation: the content-mapper, typescript-plugin, language-server and vscode-plugin projects (787 tests) pass; the typecheck of typescript-plugin, content-mapper and vscode-plugin is clean, and so are format:check and changeset:check; all 19 editor scenarios pass in VS Code 1.140.0 on macOS.

🤖 Generated with Claude Code


Note

High Risk
Large cross-cutting change to how .tsrx is type-checked and served in editors (new mapper process, dual backends, VS Code/TS version matrix); regressions could affect diagnostics, LSP features, or CI on all supported TypeScript versions.

Overview
Adds native TypeScript 7 support for .tsrx via a new @tsrx/content-mapper package: TypeScript 7’s content-mapper protocol (tsc --runExternalCode / tsc --lsp) type-checks .tsrx using the same type-only transform as the classic Volar/tsserver path, with bundled dist/ exports, benchmarks, and rollout/compatibility docs.

Tooling and editors: tsrx-tsc switches to native tsc on TS 7.1 nightlies when contentMappers is configured; @tsrx/language-server gains classic / native / plugin backends (slim TSRX-only features on native/plugin); the VS Code extension activates Microsoft’s TypeScript servers, contributes the tsserver plugin for 5.9/6, registers content mappers for TS 7, adds status/restart/commands, Prettier-based formatting, and coordinated JSX closing-tag behavior. @tsrx/typescript-plugin shares transform.js, embeds <script> bodies in generated TSX, filters noisy tsserver diagnostics on fatal compile errors, and adds closing-tag / go-to-source-definition fixes.

Diagnostics and core: TSRX errors use TSRX codes with ignore directives so each mistake reports once; @tsrx/core/diagnostics is tree-shakeable; non-code <script type="…"> bodies skip TS regions; loose-parser unclosed tags stay unclosed in editor output.

Repo: Root typecheck moves to tsc with the native TS 7 catalog and includes @tsrx/content-mapper; mapper startup no longer depends on loading TypeScript’s JS API.

Reviewed by Cursor Bugbot for commit ad24d52. Bugbot is set up for automated code reviews on this repo. Configure here.

leonidaz and others added 13 commits September 18, 2026 17:21
…rt (#41)

- pin the TypeScript 7 nightly platform packages (7.1.0-dev.20260918.1) at the
  repository root so the native tsc binary is available without a bin conflict
- add the packages/content-mapper skeleton with the consumer parity fixture,
  the classic tsrx-tsc reference (expected-diagnostics.json) and a test that
  verifies it
- inventory every mapping site by mapping_data variant (MAPPING.md)
- delete the dead suppressedDiagnostics plumbing: no transform in this repo or
  in Ripple ever produced it

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…se 1)

- @tsrx/typescript-plugin: factor the type-only transform into a pure
  transform_tsrx() (src/transform.js) with no Volar types; language.js and the
  mapper both consume it. Export require_tsrx_compiler/get_tsrx_compiler.
- @tsrx/content-mapper: stdio JSON-RPC server (initialize/openProject/
  transform/closeProject), Volar mapping → span map conversion (Verbatim/Atom/
  Alias, feature bits, disjoint generated spans), embedded <script> bodies as
  supplemental outputs, compile errors as mapper diagnostics with an export
  stub fallback, dynamicConfig identity/watchedFiles, option validation and a
  documented compiler precedence rule (entry options > tsrx.compiler >
  auto-detect).
- Tests: unit tests for span mappings, the export stub and the mapper; native
  tsc --runExternalCode integration tests against the React consumer fixture,
  per-target fixtures for Preact, Solid, Vue and Ripple with classic/native
  diagnostic parity, and a third-party stub compiler that proves Alias spans
  show authored identifiers.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tsc (#41, Phase 2)

- declaration emit: Component.d.tsrx.ts + maps, supplemental <script>
  declarations as .mts modules, generics preserved, consumption of the emitted
  declarations from a separate project with TypeScript 5 and 7 without the
  mapper (allowArbitraryExtensions)
- incremental: no-op second run, re-check on .tsrx edits, config-identity
  invalidation when the tsconfig chain changes, file add/delete/rename
- --build with project references: the referencing project declares the
  mapper too so .tsrx inputs redirect to the library's declaration output;
  the composite + supplemental <script> TS6307 limitation is pinned
- --watch: initial compilation asserted; the nightly never recompiles on edit
  on macOS (plain projects too), documented as an upstream limitation
- <script> supplemental outputs switch from .ts to .mts (module scope)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
It resolved against a second vite instance, which broke the hono test and
website typechecks with conflicting Vite types. The Vue target fixture now
borrows vue-jsx-vapor from the Vite Vue plugin's install, and the lockfile is
rebuilt from main plus the new entries only.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…able entry (#41, Phase 3)

Move the JSON-RPC framing into src/rpc.js and export the mapper, transport and
protocol modules, so a host that bundles the mapper (the VS Code extension for
inferred projects) can start it from its own entry without the main guard.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ervice-typescript (#41, Phase 3)

Add --typescript-backend=<classic|native> (or the typescriptBackend
initialization option). On the native backend TypeScript 7 owns every
TypeScript feature for .tsrx through @tsrx/content-mapper, so the server only
registers the TSRX-owned plugins (snippets, CSS, symbols, auto-insert,
CSS-class hover and definition, keyword highlights); the hover, definition and
highlight plugins now work without typescript-semantic, and the
volar-service-typescript patch is applied lazily on first classic use.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…entMappers (#41, Phase 3)

Add the tsrx.typescript.backend setting (auto/classic/native). On the native
backend the extension activates the TypeScript 7 extension, registers the
bundled @tsrx/content-mapper for inferred projects (disposed on deactivate and
re-registered when that extension reloads), skips the built-in TypeScript
extension patch and its useTsgo warning, and starts the TSRX language server
with typescriptBackend=native. auto picks native when the TypeScript 7
extension is installed and enabled. The extension also activates on
onLanguage:tsrx, declares untrustedWorkspaces.supported=false, and prompts for
an extension restart when the resolved backend changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…or editor features (#41, Phase 3)

Add tests/lsp-client.js and native-lsp.test.js: dynamic .tsrx registration,
pull diagnostics, hover, definition, references, document highlights, rename
(Verbatim works, Atom returns nothing), auto-import (extending an import
works; a new import statement is dropped, microsoft/TypeScript#64119),
compile-failure stub, two configured projects, server restart, the
runExternalCode trust gate (mapper never spawned without it), and inferred
projects through custom/setContentMapperContributions.

Coalesce neighbouring Verbatim spans across identical gaps so a whole import
statement is one edit-safe span (this is what makes the auto-import edit
applicable), and drop partial-identifier Atom spans such as the file-start
anchor.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…, Phase 3)

Checking the Ripple playground with native tsc surfaced a TS1003 in virtual
code: the Ripple compiler copies <script> bodies into the JSX of the element,
so a '<' inside one (1 < 2) parses as a tag. The classic path only hid it
because Volar drops unmapped diagnostics. Blank the body in the shared
transform (same length, line breaks kept); it is checked as the embedded
script / supplemental output. The consumer fixture now carries such a body so
the parity, native tsc and LSP tests cover it. Record the Ripple playground
parity result in the README for the Phase 4 compatibility matrix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…hase 3)

Document the classic and native TypeScript backends for Zed, Neovim,
JetBrains IDEs and Sublime Text (which gains a README), stating per editor
what is verified in this repository and what the editor can run today. The
Neovim plugin gains a typescript_backend setup option that starts the TSRX
server with --typescript-backend=native and registers the tsrx filetype and
runExternalCode with nvim-lspconfig's tsc (TypeScript 7) config.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…sults (#41, Phase 4)

- bench/bench.js measures cold and warm (--incremental) checks, single-edit
  latency through the language servers, peak process-tree RSS and process
  counts for tsrx-tsc/TSRX server (classic) against tsc --runExternalCode and
  tsc --lsp (native) on the same tsconfig, with repeated runs
- tests/lsp-client.js can drive any stdio server (the classic TSRX server for
  push diagnostics), exposes the pid, notification listeners and extra
  text-document capabilities
- BENCHMARKS.md records the method and five-run results for the consumer
  fixture (x1, x25, x100) and the Ripple playground; raw reports under
  bench/results/2026-09-18-macos-x64/
- the scaled fixture includes every copied importer; bench/ is typechecked

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…path (#41, Phase 4)

Every observed classic-versus-native difference classified as compiler-version,
previously hidden, adapter bug (fixed), adapter design, upstream limitation or
client requirement, with the pinning test or probe per row, plus the surfaces
not exercised yet and the upstream items to file.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…backend decision (#41, Phase 4)

ROLLOUT.md is the release note for the first native TypeScript 7 release:
what ships per package, the default-backend decision (classic for the CLI and
language server, auto for VS Code) with the criteria for flipping it, migration
steps for the CLI, VS Code and other editors, and rollback per surface. The
content-mapper README's Phase 3 compatibility notes are replaced by pointers to
COMPATIBILITY.md, BENCHMARKS.md and ROLLOUT.md; the language-server and VS Code
READMEs and the three changesets link to them.

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

vercel Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tsrx-website Ready Ready Preview Sep 22, 2026 12:46am UTC
tsrx-website-mcp Ready Ready Preview Sep 22, 2026 12:46am UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Autofix Details

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Stub re-exports drop type-only
    • The compile-failure stub now reprints exportKind and per-specifier type flags so type-only re-exports stay type-only.
  • ✅ Fixed: Reopen drops last-good stub
    • openProject now carries last-good source ASTs across the same project handle so a still-broken file keeps its export stub after reopen.

Create PR

Or push these changes by commenting:

@cursor push 320ed20df9
Preview (320ed20df9)
diff --git a/packages/content-mapper/src/export-stub.js b/packages/content-mapper/src/export-stub.js
--- a/packages/content-mapper/src/export-stub.js
+++ b/packages/content-mapper/src/export-stub.js
@@ -25,8 +25,11 @@
 	for (const statement of program?.body ?? []) {
 		switch (statement.type) {
 			case 'ExportAllDeclaration': {
+				const type = is_type_export(statement) ? ' type' : '';
 				const exported = statement.exported ? ` as ${export_name(statement.exported)}` : '';
-				lines.push(`export *${exported} from ${JSON.stringify(String(statement.source.value))};`);
+				lines.push(
+					`export${type} *${exported} from ${JSON.stringify(String(statement.source.value))};`,
+				);
 				break;
 			}
 			case 'ExportDefaultDeclaration':
@@ -34,13 +37,15 @@
 				break;
 			case 'ExportNamedDeclaration': {
 				if (statement.source) {
+					const declaration_is_type = is_type_export(statement);
 					const specifiers = statement.specifiers.map((specifier) => {
 						const local = export_name(specifier.local);
 						const exported = export_name(specifier.exported);
-						return local === exported ? local : `${local} as ${exported}`;
+						const type = !declaration_is_type && is_type_export(specifier) ? 'type ' : '';
+						return local === exported ? `${type}${local}` : `${type}${local} as ${exported}`;
 					});
 					lines.push(
-						`export { ${specifiers.join(', ')} } from ${JSON.stringify(String(statement.source.value))};`,
+						`export${declaration_is_type ? ' type' : ''} { ${specifiers.join(', ')} } from ${JSON.stringify(String(statement.source.value))};`,
 					);
 					break;
 				}
@@ -77,6 +82,14 @@
 }
 
 /**
+ * @param {object} node
+ * @returns {boolean}
+ */
+function is_type_export(node) {
+	return /** @type {{ exportKind?: string }} */ (node).exportKind === 'type';
+}
+
+/**
  * @param {AST.Identifier | AST.Literal | AST.Expression} node
  * @returns {string}
  */

diff --git a/packages/content-mapper/src/mapper.js b/packages/content-mapper/src/mapper.js
--- a/packages/content-mapper/src/mapper.js
+++ b/packages/content-mapper/src/mapper.js
@@ -87,7 +87,15 @@
 		// (installed compilers, package manifests) may be stale.
 		invalidateCompilerResolutionCaches();
 		const { options, optionDiagnostics } = validate_options(params.options);
-		const state = create_project_state(params.configFileName || undefined, options);
+		// Reopen keeps last-good source ASTs so a file that is still failing to
+		// compile continues to emit its export stub after tsconfig or compiler
+		// identity changes.
+		const previous = projects.get(params.projectHandle);
+		const state = create_project_state(
+			params.configFileName || undefined,
+			options,
+			previous?.lastGood,
+		);
 		projects.set(params.projectHandle, state);
 
 		// Resolve the compiler once up front so the tsconfig chain and the
@@ -220,14 +228,15 @@
 	/**
 	 * @param {string | undefined} config_file_name
 	 * @param {MapperOptions} options
+	 * @param {Map<string, AST.Program>} [last_good]
 	 * @returns {ProjectState}
 	 */
-	function create_project_state(config_file_name, options) {
+	function create_project_state(config_file_name, options, last_good) {
 		return {
 			configFileName: config_file_name ? path.normalize(config_file_name) : undefined,
 			options,
 			dependencies: new Set(),
-			lastGood: new Map(),
+			lastGood: last_good ?? new Map(),
 		};
 	}
 

diff --git a/packages/content-mapper/tests/export-stub.test.js b/packages/content-mapper/tests/export-stub.test.js
--- a/packages/content-mapper/tests/export-stub.test.js
+++ b/packages/content-mapper/tests/export-stub.test.js
@@ -44,4 +44,19 @@
 		expect(text).toContain(`export { x, y as z } from "./c.tsrx";`);
 		expect(text).toContain('declare const _default: any;\nexport default _default;');
 	});
+
+	it('keeps type-only re-exports as type-only', () => {
+		const text = stub(`
+export type { Foo, Bar as Baz } from './types.tsrx';
+export { type Qux, value } from './mixed.tsrx';
+export type * from './all-types.tsrx';
+export type * as ns from './ns.tsrx';
+`);
+		expect(text).toContain(`export type { Foo, Bar as Baz } from "./types.tsrx";`);
+		expect(text).toContain(`export { type Qux, value } from "./mixed.tsrx";`);
+		expect(text).toContain(`export type * from "./all-types.tsrx";`);
+		expect(text).toContain(`export type * as ns from "./ns.tsrx";`);
+		expect(text).not.toMatch(/export \{ Foo/);
+		expect(text).not.toMatch(/export \* from "\.\/all-types/);
+	});
 });

diff --git a/packages/content-mapper/tests/mapper.test.js b/packages/content-mapper/tests/mapper.test.js
--- a/packages/content-mapper/tests/mapper.test.js
+++ b/packages/content-mapper/tests/mapper.test.js
@@ -192,6 +192,28 @@
 		expect(first.text).toBe('export {};\n');
 	});
 
+	it('keeps the last-good export stub after TypeScript reopens the project', () => {
+		const mapper = create_tsrx_content_mapper();
+		const config = path.join(consumer_fixture_dir, 'tsconfig.json');
+		const open = () =>
+			mapper.openProject({
+				configFileName: config,
+				projectHandle: 'p1',
+				compilerOptions: {},
+			});
+		open();
+		const file = path.join(consumer_fixture_dir, 'Panel.tsrx');
+		mapper.transform({ fileName: file, content: fixture('Panel.tsrx'), projectHandle: 'p1' });
+		const broken = fixture('Panel.tsrx').replace('{label}', '{{{label}');
+		const before = mapper.transform({ fileName: file, content: broken, projectHandle: 'p1' });
+		expect(before.text).toContain('export declare const PanelProps: any;');
+		open();
+		const after = mapper.transform({ fileName: file, content: broken, projectHandle: 'p1' });
+		expect(after.text).toBe(before.text);
+		expect(after.diagnostics).toHaveLength(1);
+		expect(after.diagnostics?.[0].code).toBe(DIAGNOSTIC_CODE_COMPILE_ERROR);
+	});
+
 	it('reports an unresolvable declared compiler as a diagnostic instead of throwing', () => {
 		// Inside this monorepo a packaged compiler is always discoverable, so the
 		// "no compiler at all" branch cannot be reached here; an explicit but

You can send follow-ups to the cloud agent here.

Comment thread packages/content-mapper/src/mapper.js Resolved
leonidaz and others added 2 commits September 18, 2026 19:39
…-failure stub (#41)

`export type { A } from`, `export type * from` and `export { type A } from`
were re-emitted as value re-exports, so the stub for a file that already
failed to compile could raise its own diagnostics under isolatedModules or
verbatimModuleSyntax and importers could lose type-only names. The stub now
reads the ESTree-TS exportKind on the statement and on each specifier.

Review finding on #135 by Cursor Bugbot.

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

openProject created a fresh lastGood map per project state, so after
TypeScript reopened a project (watched tsconfig or compiler manifest change)
a .tsrx file that still failed to compile got an empty export stub and its
importers lost the preserved export surface. The last-good ASTs are keyed by
file name and independent of the project, so they now live at the mapper
level and survive reopens with the same or a new handle, and close/reopen.

Review finding on #135 by Cursor Bugbot.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…-watch (#41)

Both items in the "upstream issues still to file" list are now filed on
microsoft/TypeScript after checking for existing reports and workarounds:

- #64350: composite projects report TS6307 for the supplemental <script>
  output. Reproduced with a dependency-free mapper; no `include` glob or
  `files` entry can name the virtual file and referenced projects must be
  composite, so there is no configuration workaround.
- #64351: `tsc --watch` never recompiles on macOS. Reproduced without a
  mapper and bisected across the nightlies to the 7.1.0-dev.20260811.1
  build; `--watchFile` strategies, directory casing, symlinks and stdin
  state make no difference, so it is distinct from #64089.

The README, COMPATIBILITY.md, ROLLOUT.md and the two pinning tests now
reference the issues instead of "not filed yet".

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
leonidaz and others added 4 commits September 19, 2026 12:30
…ipt 7 package (#41)

The classic path (tsrx-tsc, the tsserver plugin, the TSRX language server)
passes its whole test suite on TypeScript 6.0.3, so the `typescript` peer
range becomes `^5.9.3 || ^6.0.0`. The `typescript@7` package is a launcher
for the native binary without a JavaScript API: tsrx-tsc, the language
server and @tsrx/content-mapper now stop with an explanation (and a pointer
to the tracking issue #136) instead of failing on its export
map, and the mapper declares the JavaScript TypeScript it needs for tsconfig
parsing as its own dependency so a TypeScript 7 project needs nothing extra.

The mapper's minimum TypeScript build is `7.1.0-dev.20260822.1`, found by
running the native test suite across the nightlies (`7.1.0-dev.20260821.1`
rejects `--runExternalCode`, `typescript@7.0.2` has no content-mapper
protocol at all); `TSRX_NATIVE_TSC` runs the suite against another build.

VS Code: the TypeScript 7 extension is looked up under the ids VS Code's own
TypeScript extension uses (adding `TypeScriptTeam.native-preview`) and every
installed one is tried for `registerContentMappers`, because the nightly
channel is a compiler-only companion. The TypeScript 7 warnings now state
what the native backend needs, say that support is not complete, link the
tracking issue and offer to open it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…matrix (#41)

Resolution: `paths` aliases, a `.tsx` importer and a workspace package behind
a `node_modules` symlink, checked against classic `tsrx-tsc` on the same
workspace. Build: a chain of mapper-backed composite projects. Editors:
inlay hints with every hint enabled (through `workspace/configuration`),
the formatting registration TypeScript 7 makes for `.tsrx` (no edits, so
Prettier must stay the `[tsrx]` default formatter), the third-party
compiler under the language server, and the built TSRX server driven over
stdio on both backends for CSS completion, hover, class definition,
document symbols and diagnostics ownership. Lifecycle: deleting and
renaming `.tsrx` files during a native session.

The LSP test client answers `workspace/configuration`, advertises file
watching and can report watched-file changes. `COMPATIBILITY.md` gains rows
37 to 50 and a shorter "not yet exercised" list.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`pnpm format:check` failed on the untracked `packages/intellij-plugin/.intellijPlatform/**`
files the plugin build generates; nothing in there is source.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…the rollout notes (#41)

llms.txt and the getting-started page gain a "Type checking" section: the
classic `tsrx-tsc` path on TypeScript 5.9 or 6, the native path through
`@tsrx/content-mapper` on a TypeScript 7.1 nightly (`7.1.0-dev.20260822.1`
or newer) with `contentMappers` and `tsc --runExternalCode`, the VS Code
`tsrx.typescript.backend` setting, and the tracking issue #136.

ROLLOUT.md records what is true on 2026-09-19: the stable 7.0 line has no
content-mapper protocol, no marketplace release of the TypeScript 7
extension exposes `registerContentMappers` yet, packaging is verified on
macOS (tarball with npm and `typescript@7` outside the checkout; the VSIX's
bundled mapper), the migration installs `typescript@next`, and Prettier
must be the `[tsrx]` default formatter. BENCHMARKS.md adds the mapper's
start-up breakdown (a third of the ~600 ms floor is TypeScript's JavaScript
API).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
leonidaz and others added 3 commits September 30, 2026 23:47
…ted code

An error's directive spanned from the first to the last generated offset
of the node that holds it. A <script> body is checked as a block at the
end of the generated file, and the React target hoists static elements
above the component, so for an element holding a script body the range
covered every component in between and hid their TypeScript errors.
Each run of the node's segments now gets its own range, ending where
code mapped from outside the node follows. Reported by Bugbot on #135.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t to do when none can

The TypeScript 7 extension 1.0.1 runs its bundled tsc 7.0.2, which cannot
run the content mapper, and VS Code's own TypeScript steps aside while
TypeScript 7 is on, so .tsrx files got no TypeScript features and
nothing said why. Neither Microsoft extension shows its version item on
.tsrx files.

- A language status item on .tsrx files names the TypeScript that
  serves them and opens the version picker, or a list of fixes.
- A notice, once per window and situation, with "Don't Show Again" per
  workspace: install the TypeScript 7 extension for a project on a 7.1
  nightly; use the project's TypeScript, install TypeScript 7 Nightly or
  turn TypeScript 7 off when TypeScript 7 runs a compiler that cannot
  check .tsrx files; install the TypeScript 7 extension when only the
  Nightly extension, which only adds a compiler, is installed.
- typescript-7.js works out the compiler the way the TypeScript 7
  extension does (tsdk settings, then the Nightly extension, then its
  bundled one); closing-tags.js shares its TypeScript 7 check.

Editor scenarios check the status and the notices, and two click a
notice button: Open Setting opens the Settings editor, and Turn Off
TypeScript 7 hands the open .tsrx file to VS Code's TypeScript without
a reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each scenario's VS Code came to the front, so nothing else could be done
while the tests ran. On macOS the runner now starts each instance with
`open -n -g -j -W`, but VS Code brings its first window to the front
itself, so a small Swift helper (hide-test-windows.swift, compiled with
swiftc per run) hides any test instance the moment macOS reports it
active, which gives the front back. Measured over a full run, the test
window was in front about 0.1 s per scenario; without swiftc the runner
falls back to polling, with a few seconds in front.

`open` hands the app its own environment, so the runner passes the
cleaned one and PATH (the content mapper runs node). Typing in the
checks is now an edit at the cursor: the `type` command needs a window
with the focus. `--foreground` keeps the old visible launch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leonidaz and others added 4 commits October 1, 2026 01:51
…next

The TypeScript 7 extension runs its built-in tsc 7.0.2, which cannot run
the content mapper, and it finds a workspace compiler only in the
retired @typescript/native-preview package (microsoft/TypeScript#64565).
Editor tests show that two user settings make it run the project's
7.1 nightly with nothing to click:

  "js/ts.experimental.useTsgo": true,
  "js/ts.tsdk.path": "node_modules/typescript"

The relative path resolves per project; a project on TypeScript 5.9 or
without typescript falls back, and VS Code's own TypeScript is not
affected when TypeScript 7 is off.

The extension README, ROLLOUT.md, the website and llms.txt now give the
same three steps (install typescript@next, add the two settings, install
the TypeScript 7 extension) and no longer recommend the TypeScript 7
Nightly extension; #991 tracks simplifying them. The README
drops the notices section. The notices no longer offer the Nightly
extension: a project without 7.1 is told to install typescript@next, one
with 7.1 to set js/ts.tsdk.path.

The editor scenarios are rebuilt around this setup (17, all passing),
including a TypeScript 5.9 project (`projectTypeScript: 'classic'`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s ask once

The settings also work in a project's .vscode/settings.json, where the
TypeScript 7 extension asks once before it uses the project's TypeScript.
That belongs next to the settings, not in the closing note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… when its tsdk changes

The 7.0.2 notice told people to open the js/ts.tsdk.path setting and
type a path. In practice the value went into the Settings search box,
and even a saved value changed nothing: the TypeScript 7 extension reads
its tsdk settings only when it starts.

- A Use Project TypeScript button writes the setting. When the open
  folder installs a 7.1 nightly, it writes "node_modules/typescript" to
  the user settings (the README's setting, no prompt); when only a
  subfolder does, or the workspace already has a tsdk setting, it
  writes the workspace settings.
- When a tsdk setting change alters the compiler TypeScript 7 should
  run, the extension restarts it: its server for a user setting, the
  extension host for a workspace one, since only its start-up asks to
  allow a workspace setting. Hand edits need no reload either.
- The README says the notice can add the setting.

The editor scenario ts7-bundled-use-project-typescript clicks the
button: TypeScript 7 then serves the .tsrx file through the project's
7.1. All 17 scenarios pass. The runner also stops a still-exiting
instance before deleting its temporary directory, which failed with
ENOTEMPTY.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was no way to restart the TSRX language server from the Command
Palette. The new command restarts it together with the TypeScript server
that serves .tsrx files: VS Code's own tsserver (typescript.restartTsServer)
with TypeScript 7 off, TypeScript 7 (typescript.native-preview.restart)
with it on. It skips the TypeScript restart when no TypeScript server
runs, and is registered before the server starts, so it can retry a
server that failed to start. The status item's fix list offers it too,
and the README has a Restarting section.

Editor scenarios can now run a command at the end; vscode-typescript-restart
and ts7-recommended-restart check that TypeScript answers again and the
TSRX server lists document symbols after the restart.

Closes #829

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leonidaz and others added 9 commits October 1, 2026 13:34
… editor tests

The fixture now has main.ts, which imports App.tsrx, which imports label.ts.
Its tsconfig.json has no `plugins` entry. Every scenario where TypeScript
serves the .tsrx file now checks both imports. All 20 scenarios pass, so
VS Code needs no tsconfig `plugins` entry on TypeScript 5.9, 6 or 7.1.

- run.js turns on the tsserver log and records each tsserver's version and
  whether it loaded @tsrx/typescript-plugin (`result.tsserver`).
- New scenario vscode-typescript-classic-project: js/ts.tsdk.path points at
  the project's TypeScript 5.9 lib folder, and the check confirms 5.9.3 runs.
- The closing-tag check reads from the position where it typed, so the
  formatted three-line <button> does not matter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngs note

- Rewrite the text after the setup steps in short sentences, with headings,
  lists, and links for the upstream issues.
- Correct the "server plugins will not be loaded" warning: quote its real
  text, say that it comes from the extension's typescriptServerPlugins
  entry (not from tsconfig.json), that it shows each time VS Code starts
  until Don't Show Again, and link microsoft/TypeScript#64356.
- New "Legacy settings" section: VS Code no longer needs the tsconfig
  `plugins` entry for @tsrx/typescript-plugin (only other editors do).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR #135 is about to merge, so the gaps and upstream issues are tracked in
the reopened issue #136 again. TYPESCRIPT_7_TRACKING_URL (used by the
tsrx-tsc, language-server and VS Code messages), the editor and package
READMEs, ROLLOUT.md, the website, llms.txt and the changeset now link it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tsserver's findSourceDefinition failed for a library symbol in a .tsrx file:

  Debug Failure. False expression: Script kind should match provided
  ScriptKind:3 and sourceFile.scriptKind: 4

To find the JavaScript behind a .d.ts file, tsserver adds the file to a
helper project (an AuxiliaryProject with noDtsResolution) and loads no
plugins into it, so that project read the .tsrx file as plain TypeScript
while the host project had registered it as TSX. The plugin now gives the
helper project the host project's Volar setup before tsserver builds it.

VS Code's typescript.tsserverRequest forwards only a few built-in requests
and those whose name starts with `_`, so the plugin also registers
`_tsrx:findSourceDefinition`, which runs the session's findSourceDefinition.

A test drives a real tsserver with the plugin as a global plugin, as VS
Code loads it; verified on TypeScript 5.9.3 and 6.0.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… .tsrx files

TSRX: Go to Source Definition used to run Go to Definition and prefer a
.tsrx result. VS Code's own command and the TypeScript 7 extension's run
only in TypeScript and JavaScript files. Now, with VS Code's own TypeScript
(5.9 or 6), the command sends @tsrx/typescript-plugin's
`_tsrx:findSourceDefinition` through typescript.tsserverRequest:
`useState` opens React's JavaScript instead of @types/react.

With TypeScript 7 it opens the definition and says why the first time:
tsc --lsp answers the request for .tsrx files, but the TypeScript 7
extension's command refuses them (microsoft/TypeScript#64576). The
TYPESCRIPT_7_SOURCE_DEFINITION flag hands over once that ships
(#992).

Both paths open results with editor.action.goToLocations and an explicit
file and position, so they work without the editor focus. The editor tests
now run the command on `useState` in every setup where TypeScript works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server now answers textDocument/formatting on every backend with the
project's own prettier and @tsrx/prettier-plugin (src/formatting.js, no
Volar import; src/formattingHandler.js on the plain LSP connection, since
Volar formats only generated code, never the .tsrx source).

- Both packages come from the node_modules folders above the file, never
  NODE_PATH. The plugin and the tsrx parser are always passed, so a .tsrx
  file formats even when the Prettier config does not list the plugin.
- The Prettier config, .editorconfig and the nearest .prettierignore apply
  as on the command line; the editor's indentation only when the project
  has neither a config nor an .editorconfig.
- A missing package or a Prettier older than 3.6 returns no edits and sends
  window/showMessage once per project, with the install command for the
  project's package manager (nearest lockfile). A file Prettier cannot parse
  is only logged. tsrx.format.enable: false turns it off.
- No Volar service plugin offers formatting (servicePlugins.test.js): one
  would make Volar replace this handler.

README: Formatting section, pnpm commands, GitHub links between packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g user settings

configurationDefaults now set "[tsrx]": { "editor.defaultFormatter":
"TSRX.tsrx-vscode-plugin" }, so Format Document and format on save use the
language server's Prettier formatting and the Prettier extension is not
needed. configurePrettier() is gone: on every start it wrote
prettier.documentSelectors and the whole [tsrx] block into the user
settings, replacing any other [tsrx] settings and selectors. The unused
tsrx.preferences.preferTypeOnlyAutoImports setting is removed, and
tsrx.format.enable now controls the formatter.

Editor tests: every scenario formats a messy Format.tsrx written into the
project copy (no Prettier extension installed) and checks the default
formatter. The formatted text is computed from the edits, never applied:
an unsaved document made VS Code ask to save it at shutdown, and that
dialog brought the hidden window to the front. Scenarios now fail if any
document is left unsaved. All 20 pass.

README: Formatting section, and the Prettier settings older versions wrote
under Legacy settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ands

- @tsrx/prettier-plugin README: a Usage section (install, Prettier config,
  command line, editors through the TSRX language server).
- IntelliJ README: formatting through the language server needs prettier
  and @tsrx/prettier-plugin in the project.
- content-mapper ROLLOUT.md: nothing to set for formatting in VS Code.
- Package READMEs link other packages with GitHub URLs: npm and the
  marketplace show each README alone, where ../other-package breaks.
- Install and run commands show a pnpm line next to the npm one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… files

The server now also answers textDocument/rangeFormatting with the
project's Prettier and @tsrx/prettier-plugin (rangeStart/rangeEnd), so
Format Selection and editor.formatOnPaste work. Before, VS Code said that
TSRX "can only format 'TSRX'-files as a whole".

The editor tests check Format Selection on one line of the messy
Format.tsrx in every scenario.

READMEs: VS Code says that Format Document With… also lists TypeScript for
.tsrx files, which cannot format them (microsoft/TypeScript#64579);
Neovim, Sublime Text and Zed get a Formatting section (Neovim:
vim.lsp.buf.format({ name = "tsrx" }) next to TypeScript 7's tsc client).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Config plugin name skips resolved path
    • format_tsrx now drops a bare @tsrx/prettier-plugin config entry and passes the plugin path already resolved from the file, so Prettier no longer re-resolves the name from its own cwd when the packages live in different node_modules trees.

Create PR

Or push these changes by commenting:

@cursor push b77c7d6d1e
Preview (b77c7d6d1e)
diff --git a/.changeset/language-server-prettier-plugin-path.md b/.changeset/language-server-prettier-plugin-path.md
new file mode 100644
--- /dev/null
+++ b/.changeset/language-server-prettier-plugin-path.md
@@ -1,0 +1,5 @@
+---
+'@tsrx/language-server': patch
+---
+
+Editor formatting of `.tsrx` files still works when the Prettier config lists `@tsrx/prettier-plugin` by package name and that plugin is installed in a different `node_modules` than Prettier. The language server passes the plugin path it resolved from the file, instead of leaving Prettier to load the bare name from its own working directory.

diff --git a/packages/language-server/src/formatting.js b/packages/language-server/src/formatting.js
--- a/packages/language-server/src/formatting.js
+++ b/packages/language-server/src/formatting.js
@@ -87,9 +87,14 @@
 			tabWidth: tab_size,
 			useTabs: !insert_spaces,
 		};
+		// A config entry of `@tsrx/prettier-plugin` is not the copy `resolve` found.
+		// Prettier loads that bare name from its own cwd, which misses a plugin
+		// installed in another `node_modules` than Prettier (a nested package).
 		/** @type {unknown[]} */
-		const plugins = Array.isArray(config.plugins) ? [...config.plugins] : [];
-		if (!plugins.includes(PRETTIER_PLUGIN)) plugins.push(plugin_entry);
+		const plugins = (Array.isArray(config.plugins) ? config.plugins : []).filter(
+			(plugin) => plugin !== PRETTIER_PLUGIN,
+		);
+		if (!plugins.includes(plugin_entry)) plugins.push(plugin_entry);
 		const formatted = await prettier.format(text, {
 			...config,
 			filepath: file_path,

diff --git a/packages/language-server/tests/formatting.test.js b/packages/language-server/tests/formatting.test.js
--- a/packages/language-server/tests/formatting.test.js
+++ b/packages/language-server/tests/formatting.test.js
@@ -76,6 +76,43 @@
 		}
 	});
 
+	it('uses the plugin resolved from the file when the config names it and the packages are in different node_modules', async () => {
+		const dir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'tsrx-format-')));
+		projects.push(dir);
+		const app = path.join(dir, 'packages', 'app');
+		fs.mkdirSync(path.join(app, 'src'), { recursive: true });
+		const file_path = path.join(app, 'src', 'App.tsrx');
+		fs.writeFileSync(file_path, MESSY);
+		fs.writeFileSync(
+			path.join(app, '.prettierrc'),
+			JSON.stringify({ singleQuote: true, tabWidth: 4, plugins: ['@tsrx/prettier-plugin'] }),
+		);
+		// Prettier at the workspace root, the plugin only in the nested package.
+		const prettier_link = path.join(dir, 'node_modules', 'prettier');
+		fs.mkdirSync(path.dirname(prettier_link), { recursive: true });
+		fs.symlinkSync(prettier_package, prettier_link, 'junction');
+		const plugin_link = path.join(app, 'node_modules', '@tsrx', 'prettier-plugin');
+		fs.mkdirSync(path.dirname(plugin_link), { recursive: true });
+		fs.symlinkSync(plugin_package, plugin_link, 'junction');
+
+		const previous = process.cwd();
+		try {
+			// Prettier resolves a bare plugin name from here, not from the file.
+			process.chdir(dir);
+			expect(await format_tsrx({ file_path, text: MESSY, insert_spaces: false })).toEqual({
+				status: 'formatted',
+				text: `import { useState } from 'react';
+export function App() @{
+    const [count, setCount] = useState(0);
+    <button onClick={() => setCount(count + 1)}>{count}</button>
+}
+`,
+			});
+		} finally {
+			process.chdir(previous);
+		}
+	});
+
 	it('reads .editorconfig', async () => {
 		const { file_path } = project({
 			files: { '.editorconfig': '[*.tsrx]\nindent_style = space\nindent_size = 3\n' },

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit bdcc301. Configure here.

…move Unused Imports for .tsrx files

VS Code's own TypeScript commands only run in TypeScript and JavaScript
files, so the menu entries that added them for .tsrx files never appeared
or refused the file:

- typescript.reloadProjects and typescript.goToProjectConfig: hidden,
  because typescript.isManagedFile is false in .tsrx editors (VS Code's
  editor tracker counts TypeScript and JavaScript only).
- typescript.findAllFileReferences: shown in the Explorer and editor-tab
  menus, then "Unsupported file type" (#993 tracks a real
  command; TypeScript 7 has none yet, microsoft/TypeScript#63806).
- typescript.sortImports and removeUnusedImports: no edits on 5.9/6
  (#994), and missing commands while TypeScript 7 is on.

Instead:
- TSRX: Go to Project Configuration opens the nearest tsconfig.json above
  the file, where TSRX reads its settings.
- TSRX: Sort Imports and TSRX: Remove Unused Imports fetch TypeScript's
  source action through vscode.executeCodeActionProvider and apply it
  (editor.action.sourceAction acts on the focused editor only). They work
  on TypeScript 7.
- TSRX: Restart Language Server covers Reload Projects; TSRX's commands
  appear in the Command Palette of a TSRX workspace (tsrx.active).

Editor tests: Go to Project Configuration in every setup, Remove Unused
Imports on a runtime-written Imports.tsrx (removed on TypeScript 7,
unchanged on 5.9/6 until #994), reverted afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…w to turn it on

- The editor tests ask VS Code's linked editing provider (the auto-rename of
  a tag pair) for the <button> tag in App.tsrx: both tag names on VS Code's
  own TypeScript and on TypeScript 7 (#827).
- README: turn on editor.linkedEditing (VS Code leaves it off for every
  language), everywhere or only for [tsrx].
- Go to Source Definition's step waits until TypeScript returns a
  definition: on TypeScript 7 the fallback sometimes ran before the
  definition's file had loaded and opened nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the formatted file

When the Prettier config listed @tsrx/prettier-plugin (or another plugin)
by package name, format_tsrx passed the name through, and Prettier resolved
it from the process's working directory. For an editor's language server
that is not the project, so in a monorepo with Prettier at the root and the
plugin in a package, formatting failed ("Cannot find package
'@tsrx/prettier-plugin' imported from …/noop.js") and returned no edits.

Plugins named by package now resolve from the node_modules folders above
the file, as the Prettier extension resolves them relative to the document;
@tsrx/prettier-plugin becomes the entry format_tsrx already resolved. A name
that is not installed stays for Prettier to report. The regression test runs
the formatter from an unrelated working directory.

Found by Cursor Bugbot on #135.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: vscode-plugin: Restart TSRX Server command missing [Bug]: vscode-plugin: Auto-rename tags [vscode]

1 participant