microsoft / microsoft/TypeScript

Expose `textChanges.ChangeTracker` for public API

Đang mở
#53,399 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Awaiting More Feedback Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

Suggestion

I'm not sure how such requests as this one suits into TypeScript repo, but I've seen such requests earlier so decided to put another one!

Motivation: Currently it's very unclear for new developers how to contribute new code actions (refactorings / quick fixes: getEditsForRefactor / getCodeFixesAtPosition) with current plugins API. While factory API is exposed AFAICS the only way to convert nodes to actual changes is ts.createPrinter().printNode, which makes passed in formatOptions useless (just always inserting semicolons is already too annoying). I don't see a reason why don't let other developers to build their own code actions in the same way as built-in bulit.

Of course I've already seen a lot of plugins using in our days, most of them are using constructor and with along with these methods: insertNodeAt, replaceNodeRange, delete and a few others. With types exposed it would be easier to use language service methods that receive formatOptions.

🔍 Search Terms

Language Service Plugins API

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

📃 Motivating Example

💻 Use Cases

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

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách đọc các điểm vào của language service plugin được nêu trong issue, đặc biệt là getEditsForRefactor và getCodeFixesAtPosition, cùng với textChanges.ChangeTracker và các phương thức insertNodeAt, replaceNodeRange và delete của nó. Xác định public API và các yêu cầu tương thích để expose ChangeTracker, bao gồm cả cách sử dụng formatOptions; hoàn tất khi surface được hỗ trợ và phương pháp validation đã rõ ràng.

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
api, 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
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/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.