Proposal: Expose LSP/Language Service capabilities (e.g., rename) via a tsc subcommand

未关闭
#64,102 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
活跃
技术栈
typescript

调研方向

首先审查现有的 tsc CLI 接口和 Language Service API,并以所描述的 gopls 重命名接口作为先例。在实现之前,定义命令形式、支持的功能以及 workspace/edit 输出行为;完成标准是为确定性的 CLI 重构工作流达成一致的范围。

由索引模型根据 Issue 内容生成。

描述

Suggestion
🔍 Search Terms

lsp rename refactor

✅ Viability Checklist
⭐ Suggestion

As AI coding agents evolve, structured program manipulation becomes increasingly vital. While tsc currently excels at type-checking and emitting JavaScript, programmatic refactoring (such as symbol renaming) is only exposed through the Language Service API in Node.js or via standard LSP integration over IPC.

To better support CLI-driven agent workflows, we should consider exposing core Language Service features through dedicated tsc subcommands (e.g., tsc rename ).

Prior Art / Motivation:
Other language toolchains already offer similar CLI interfaces for headless program transformation. For instance, Go provides native subcommand/tooling support via gopls (e.g., gopls rename ...), allowing external CLI tools and AI agents to execute deterministic, workspace-wide symbol renames without needing to boot a full LSP client or write custom Node.js wrappers around typescript.createLanguageService.

Exposing this in tsc would provide:

A standardized, zero-dependency CLI interface for AI agents to perform refactoring safely.

Deterministic AST/type-aware renaming out of the box for automated workflows.

Reduced friction for CLI tool developers who currently have to mock or bridge LSP protocols.

📃 Motivating Example
 $ gopls rename --help
rename selected identifier

Usage:
  gopls [flags] rename [rename-flags] <position> <name>

Example:

        $ # 1-based location (:line:column or :#position) of the thing to change
        $ gopls rename helper/helper.go:8:6 Foo
        $ gopls rename helper/helper.go:#53 Foo

rename-flags:
  -d,-diff
        display diffs instead of edited file content
  -l,-list
        display names of edited files
  -preserve
        with -write, make copies of original files
  -w,-write
        write edited content to source files
💻 Use Cases
  1. agent vibe coding
主要语言
Go
星标
111k
派生
14.4k
平均合并
1 天 19 小时
30 天内合并 PR
117

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/TypeScript 的其他 Issue

查看 microsoft/TypeScript 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。