microsoft / microsoft/TypeScript

Display signature help or completions for tuples with labels

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

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

Experience Enhancement Help Wanted 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

🔍 Search Terms

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:

  • [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 feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

📃 Motivating Example

declare const coords: [x: number, y: number]

const [/**/] = coords

The problem: having no idea what a name to type as you don't know what the type of it.

I'm using it with my plugin and it looks very simple (and useful IMO):

Of course, you can hover of the variable to fiture it out, but what about the following example:

const a: {
    coords: [x: number, y: number] | string | { x: number; y: number }/* | even more types */
} = {
    coords: [/**/], // the type with x, y tuples can be even truncated, so you can only guess names of labels
}

I understand that labeled tuples introduced in ts4.0 were designed primarily for parameters usage, but I've seen them used for shorter static data declarations as well.

However, if you think that usage signature help is redundant and incorrect, what about having completions for tuple labels at least? There is already completions when acessing such symbols via dot property access. For example for first example it would be keyword completion with label x and [0]: number detail.

💻 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 việc xem xét các ví dụ về labeled-tuple và hai hành vi được đề xuất: signature help trong khi destructuring tuple và completions cho tuple labels. Xác định hành vi nào nên được hỗ trợ và hành vi đó nên hoạt động như thế nào đối với unions hoặc truncated tuple types, sau đó xác định các entry point và test liên quan của TypeScript language-service. Hoàn thành có nghĩa là tương tác được chọn cung cấp thông tin hữu ích về label mà không thay đổi runtime output.

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
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
35/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.