microsoft / microsoft/TypeScript
Go to definition for class members hidden with Symbols takes to symbol itself
Chưa có ai nhận issue này.
- 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ả
As a developer working with Custom Elements classes that have their class members available in runtime, I would like to use Symbol to hide internal methods and properties from the public API.
The drawback of this approach is that "go to definition" currently does not recognise the case when Symbol is used for a method, and jumps to the place where the Symbol itself is defined.
I'm not sure whether this is a bug or feature.
TypeScript Version: 3.8.0-dev.20191126
Search Terms: Go to definition, ECMAScript Symbols, Symbol
Code
const method = Symbol('method');
class Parent {
protected [method]() {
return 'parent';
}
}
class Child extends Parent {
protected [method]() {
return super[method]() + ' child';
}
}
Expected behavior:
When clicking on super[method], it should be possible to go to the line 4.
Actual behavior:
When clicking on super[method], go to definition moves to the line 1.
Related Issues:
I didn't found any related issue but the approach with using ES2015 Symbols was suggested to be used as a workaround for protected methods in mixins at https://github.com/microsoft/TypeScript/issues/17744#issuecomment-431534647
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với TypeScript playground được liên kết và tái hiện go-to-definition trên super[method] trong các lớp Parent và Child được cung cấp. Truy vết điểm vào của language service dành cho các thành viên symbol được tính toán; hoàn tất khi điều hướng đến phương thức Parent ở dòng 4 thay vì khai báo Symbol ở dòng 1.
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
- tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100