@fluixi/ts-plugin

中文文档
1.0.0-alpha.108发布于 2026/11/07MITTypeScriptCommonJS近 30 天下载 2329

gives html`` templates the editor support JSX already gets; a component used only as a tag is no longer reported as unused

原始使用文档
文档目录5 节
  1. The problem
  2. What you get
  3. Enable it
  4. How it stays out of the way
  5. License

@fluixi/ts-plugin

A TypeScript language-service plugin that gives html`...` templates the same editor support JSX gets.

The problem

TypeScript sees a tagged template as an opaque string. Everything inside it falls off the map: a component referenced only by tag is reported "declared but never used", a callback param is an implicit any, nothing completes, hover says nothing, and go-to-definition lands on the template literal instead of the component.

function UserCard() { /* … */ }

const app = html`<main><UserCard /></main>`;
//                      ^ greyed out — TypeScript never counted this as a reference

Authoring in html `` shouldn't cost you the editor.

What you get

Reparse the template with @fluixi/template-parser, map every tag and hole back to a real source position, and ask the program's own checker about it:

  • Hover: a component tag shows its signature, a prop shows its declared type, an element attribute shows what it takes, and an inferred callback param (each, event, ref, use, Show) shows the type it was inferred to.
  • Completion: component prop names inside a tag, element attributes on an intrinsic tag, and members of an inferred param (it., el., e.).
  • Navigation: go-to-definition, find-all-references and rename work through tags. Rename only adds tags when TypeScript's own rename succeeded, so you never get a rewritten <Tag> with a stale </Tag>.
  • Diagnostics: a bare accessor in a template (html`<p>${count}</p>`) is flagged, since it renders the function once and never updates; a property that doesn't exist on an inferred param is reported.
  • Quiet where it should be: unused-component reports and implicit-any noise on params the template can infer are dropped.
  • Quick fixes: "Call count" for a bare accessor, with a fix-all for the file.

Enable it

Add it to your project's tsconfig.json and use the workspace TypeScript version (VS Code: TypeScript: Select TypeScript Version → Use Workspace Version: tsconfig plugins only load under the workspace TS):

{
  "compilerOptions": {
    "plugins": [{ "name": "@fluixi/ts-plugin" }]
  }
}

Nothing else. JSX needs no plugin, and neither do the $signal-style intrinsics: those are typed by the fluixi.d.ts the compiler generates.

How it stays out of the way

Everything is computed on the existing program's checker. The plugin creates no language service, adds no files, and never touches the host: it wraps the service it's handed, and every addition is wrapped so a failure costs the extra information, never the real answer.

That restraint is deliberate. Two earlier designs for deep type-checking inside ${...} holes both had to go: a second ts.LanguageService meant a second document registry, so lib.d.ts and node_modules were parsed twice; and shadow files added via getScriptFileNames re-entered host machinery on every project sync and crashed the language service outright. Hole diagnostics weren't worth either: a ${...} hole is a real expression, so TypeScript already checks it.

License

MIT

版本与发布记录

@fluixi/ts-plugin 共发布 42 个版本,首次发布于 2026/07/13;过去 12 个月发布了 42 个版本。

版本发布日期距今
1.0.0-alpha.108latest2026/11/078 天前
1.0.0-alpha.1072026/11/0511 天前
1.0.0-alpha.1062026/11/0213 天前
1.0.0-alpha.1052026/11/0115 天前
1.0.0-alpha.1042026/11/0115 天前
1.0.0-alpha.1032026/10/2620 天前

关于 @fluixi/ts-plugin 的常见问题

@fluixi/ts-plugin 是什么?

gives html`` templates the editor support JSX already gets; a component used only as a tag is no longer reported as unused

如何安装 @fluixi/ts-plugin?

在项目目录运行 npm install @fluixi/ts-plugin,或使用 pnpm add / yarn add / bun add。

@fluixi/ts-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fluixi/ts-plugin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fluixi/ts-plugin 可以商用吗?

@fluixi/ts-plugin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fluixi/ts-plugin 的下载量有多少?

根据 npm 官方下载统计,@fluixi/ts-plugin 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,329 次,日均约 78 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fluixi/ts-plugin 还在维护吗?

最新版本 1.0.0-alpha.108 发布于 2026/11/07(8 天前);至今共发布 42 个版本,其中过去 12 个月发布了 42 个;首次发布于 2026/07/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。