microsoft / microsoft/TypeScript

Code fix spelling suggestions for class fields based on lexical scope

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

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

Needs More Info 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

Issue raised to separately track discussion started here: https://github.com/microsoft/TypeScript/pull/44648/files#r709632217 as suggested by @sandersn

Right now code fix spelling suggestions for property names are based on the receiver type. When the receiver type is wide, perhaps unknown, further correct candidate names could be collected from the fields in any surrounding classes. This could potentially only apply to private fields, where they can only be used within the class, or extended to all fields.

🔍 Search Terms

spelling, suggestion, code fix, class fields, private fields

✅ 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

class MyClass {
  #brand;
  
  static isMyClass(v: object): v is MyClass {
    return #brad in v; // provide code-fix here: change 'brad' to 'brand'
  }
}

Private field lookup, unlike traditional property look up, is scoped to within the class. This provides a finite, and lexically discoverable, set of candidate field names.

💻 Use Cases

The reciever type can be too wide to use for candidate names in these cases:

❔ Questions

from here

  • How much does it improve real-world recall?
  • How much does it hurt precision?
  • Should it only apply to #privates?
  • Does iterated lookup hurt performance? (Probably not, but worth thinking about a little.)
  • When the type is explicitly any or unknown, shouldn't the editor first suggest a specific type or narrowing for the receiver?

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 với cuộc thảo luận về việc sửa mã gợi ý chính tả được liên kết từ issue, bao gồm cả phần review pull request TypeScript được tham chiếu. So sánh ví dụ về trường private với các gợi ý hiện có về kiểu receiver và giải quyết các câu hỏi còn bỏ ngỏ về phạm vi, độ chính xác và hiệu năng; issue không nêu tên các tệp triển khai hoặc bài kiểm thử, và tiêu chí hoàn thành vẫn chưa được quyế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ệ
javascript, typescript
Lĩnh vực
devtools
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
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.