Default type parameter values always shown on hover

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

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

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript

Hướng nghiên cứu

Không có tệp nguồn hoặc bài kiểm thử nào được nêu. Hãy bắt đầu với TypeScript Playground được liên kết và kiểm tra phần hover của SomeHkt, sau đó lần theo đường dẫn của compiler xử lý việc định dạng các tham số kiểu generic. Công việc được xem là hoàn tất khi các tham số có giá trị mặc định được lược bỏ nếu chưa được thiết lập hoặc được đặt rõ ràng bằng đúng các giá trị mặc định của chúng, bao gồm các trường hợp .d.ts và isolatedDeclarations đã nêu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Awaiting More Feedback Suggestion
🔎 Search Terms

default parameters hover

🕗 Version & Regression Information
  • This is the behavior in every version I tried
⏯ Playground Link

https://tsplay.dev/mpkKgN

💻 Code
export abstract class Kind<
    hkt extends (...args: any[]) => unknown = (...args: any[]) => unknown
> {
    declare readonly args: unknown
    abstract readonly hkt: hkt
}

// Hover: Kind<(...args: any[]) => unknown>
type SomeHkt = Kind
🙁 Actual behavior

Kind's defaulted parameter is displayed on hover.

🙂 Expected behavior

Defaultable generic parameters should not be printed if they are unset in the instantiation and/or explicitly set to their default value.

This could also apply to .d.ts, although that's viewed less often.

Additional information about the issue

This is obviously not a bug but a request that would help reduce visual clutter for many types. Types with several parameters with non trivial default values are relatively common, especially when those defaults are expanded recursively.

It also occurred to me that when combined with autofixes, this could also make types written to a user file much more usable. When using --isolatedDeclarations, one of the biggest problems with the autofixes is that they'd often pull in types with several generic parameters with long defaults, and end up writing some massive type instead of just a single identifier.

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

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.

Issue khác của microsoft/TypeScript

Tất cả issue của microsoft/TypeScript

Issue tương tự

Thêm issue về Go

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.