Ship a TypeScript 7.1 content mapper for .rx, so tsgo/tsrs check .rx in one pass

未關閉
#82 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
node.js, typescript

研究方向

Read notes/contentmappers.md and the sample at testdata/contentmapper/header-mapper/mapper.mjs to understand the protocol, then inspect the crate’s existing TSX projection and checker diagnostics mentioned in the issue. Determine how a wrapper can expose those outputs through initialize, openProject, transform, and closeProject; done means TS 7.1 and tsrs report both TypeScript and checker diagnostics for .rx in one pass.

由索引模型根據 Issue 內容生成。

描述

Proposal

Ship a TypeScript 7.1 content mapper for .rx, beside (or eventually instead of) the Volar language plugin.

Why

rx-tsc and the language server run on Volar over TypeScript's JS API (typescript 6.x). TypeScript 7 (the Go compiler) has no plugin API of that kind. Projects that have moved their type checking to TS 7 or tsrs (the Rust port, which also hosts oxlint's type-aware rules) are left with two problems:

  • They must run a second, slower checker just for .rx.
  • Their editor's TS 7 language server doesn't know .rx exists.

TypeScript 7.1 defines the extension point for this: content mappers. Here is how it works:

  1. A tsconfig declares "contentMappers": [{ "package": "…", "extensions": [".rx"] }], and the package's package.json names an executable under typescript.contentMapper.exec.
  2. The compiler spawns that executable with --runExternalCode and talks JSON-RPC over stdio. The methods are initialize, openProject, transform and closeProject.
  3. transform returns { text, extension: ".tsx", mappings: [[virtualStart, virtualLength, originalStart, originalLength, kind]], diagnostics }.

The compiler checks the virtual file as part of the program. It reports type errors at the original positions, and reports the mapper's own diagnostics as well.

tsrs implements this in the compiler, -b/incremental builds, the language server, the Node API and its linter. References: notes/contentmappers.md, and the ~80-line sample mapper in testdata/contentmapper/header-mapper/mapper.mjs.

Why it fits .rx well

The crate already produces everything transform needs:

  • the TSX projection with exact mappings onto the .rx (spec/11 CP-8c, spec/13 TY-1c, rxc project);
  • its own checker diagnostics with ranges, which map onto the mapper's diagnostics.

So tsc -p, tsgo and tsrs -p would report TypeScript errors and checker errors for .rx in one pass, with no Volar in between. A small Node (or native) wrapper around the existing analysis would be enough. The Volar plugin can stay for TS 6 editors.

Context

We tried 0.3.1 in a Solid 2 app whose type checking runs on tsrs. rx-tsc works (it places TS errors on .rx correctly), but only as a separate pass on TypeScript 6.

主要語言
TypeScript
星號
127
分支
7
平均合併
15 小時 42 分鐘
30 天內合併 PR
63

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

solidjs/reactivescript 的其他 Issue

查看 solidjs/reactivescript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。