microsoft / microsoft/TypeScript

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

Đang mở
#64,102 3 bình luận 1 reaction 0 người được giao Xem trên GitHub
Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

### 🔍 Search Terms

lsp rename refactor

### ✅ Viability Checklist

- [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [x] This wouldn't change the runtime behavior of existing JavaScript code
- [x] This could be implemented without emitting different JS based on the types of the expressions
- [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- [x] This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- [x] This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals

### ⭐ 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]

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách xem xét bề mặt CLI tsc hiện có và Language Service API, sử dụng giao diện đổi tên của gopls được mô tả làm cơ sở tham khảo. Xác định hình dạng lệnh, các khả năng được hỗ trợ và hành vi đầu ra của workspace/edit trước khi triển khai; công việc được xem là hoàn tất khi có phạm vi đã thống nhất cho một workflow tái cấu trúc CLI mang tính tất định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
typescript
Lĩnh vực
cli, developer-experience
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.