Skip to content

fix(typescript-plugin): apply tsc patches under Deno - #133

Merged
leonidaz merged 1 commit into
mainfrom
fix/deno-tsc-loader
Sep 18, 2026
Merged

leonidaz merged 1 commit into
mainfrom
fix/deno-tsc-loader

Conversation

@leonidaz

@leonidaz leonidaz commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Running tsrx-tsc under Deno reports TS2307 for .tsrx imports because Deno's CommonJS loader bypasses the fs.readFileSync hook that Volar uses to patch TypeScript's CLI.

Add a node:module.registerHooks load hook for the resolved TypeScript CLI entry. It reads through Volar's patched reader and deregisters before loading the consumer compiler and its dependencies. Older Node versions without registerHooks retain the existing loading behavior, so no minimum Node version increase is needed.

Add regression coverage for normal loading, loading that bypasses the filesystem hook, and the older Node fallback. The tests check imports, diagnostics, TypeScript version reporting, and hook cleanup. Include Deno task documentation and a patch changeset.

Fixes #128.

Validation:

  • pnpm test --project typescript-plugin — 178 tests passed.
  • pnpm exec tsgo --noEmit -p packages/typescript-plugin/tsconfig.typecheck.json.
  • Prettier checks for all changed files, git diff --check, and pnpm changeset:check.
  • pnpm --filter @tsrx/typescript-plugin build.
  • Built CLI with TypeScript 5.9.3: valid projects pass and type errors in .tsrx files and their TypeScript consumers are reported correctly under Node 22.14.0, 22.23.2, 24.18.0, 26.9.0, and Deno 2.9.6.

Note

Low Risk
Scoped to the tsrx-tsc CLI entry load path with deregistration and multi-loader tests; no change to editor/tsserver behavior beyond the same Volar patch applying in Deno.

Overview
Fixes tsrx-tsc under Deno (and similar loaders) where TypeScript’s CLI was loaded without Volar’s patch, causing TS2307 on .tsrx imports.

The CLI now optionally registers a node:module load hook for the resolved typescript/lib/tsc.js URL so that entry is read while Volar’s fs.readFileSync patch still applies; the hook deregisters right after that load (and in a finally block) so later compiler resolution uses normal loading. Node without registerHooks keeps the previous behavior.

Adds Vitest coverage for native, Deno-like bypass, and legacy (no hooks) loaders—.tsrx resolution, diagnostics, --version, and hook/fs cleanup. README documents tsrx-tsc and a Deno 2.8+ deno task check example without a custom loader.

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

@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 18, 2026 5:57pm UTC
tsrx-website-mcp Ready Ready Preview Sep 18, 2026 5:57pm UTC

Request Review

This branch was successfully deployed

2 active deployments
Preview – tsrx-website — cc892a4e Deployed Sep 18, 2026 by vercel[bot]
Preview – tsrx-website-mcp — cc892a4e Deployed Sep 18, 2026 by vercel[bot]
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.

Deno support: how to get the type checking working under Deno?

1 participant