microsoft / microsoft/TypeScript

Go to definition for class members hidden with Symbols takes to symbol itself

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

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

Experience Enhancement 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ả

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.

Playground Link: https://www.typescriptlang.org/play/?ts=3.8.0-dev.20191126&ssl=1&ssc=1&pln=38&pc=2#code/MYewdgzgLgBAtgUygCxAExgXhgZQJ5wBGIANgBQDkiK6FAlANwBQTwJAhhBDAArsBOCMLADeTGBJgAHfiCgJg8jAG1qqNAF0ydGGMn6YgqAFd+YGBSkChUCs30BfJk9YcuMAMLIAliQwIAD3kwNG4+QWFdcUkZOQUlGFUkdS0dPQMJI1NzCGMpBH4kmk1tGABqCxhgHz87aIknJyA

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

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 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

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.