microsoft / microsoft/TypeScript

Intersection type intellisense duplicates jsdoc, rather than overriding

Đang mở
#30,901 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 Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

  • VSCode Version: 1.33.1
  • OS Version: macOS 10.12.6

Does this issue occur when all extensions are disabled?: Yes


Sorry if the title isn't clear, it's tricky to put into words but obvious with code. The gist is when a type is extended and has the same key, the intellisense combines the documentation, rather than the "child" overriding it, like they do with interface. It's easier to explain with an example.

When intersecting types with the same property, the intellisense documentation shows all of the comments instead of just the latest:

type Duck {
  /** This is a really great duck */
  id: string
}

type Mallard = Duck & {
  /** I love this duck */
  id: string
}

const duckMan: Mallard = {
  id   // intellisense here shows "This is a really great duck I love this duck"
}
Pasted_Image_4_12_19__4_05_PM

However, with an interface, the intellisense shows only the direct type comment, which is expected.

interface Duck {
  /** This is a really great banana */
  id: string
}

interface Mallard extends Duck {
  /** I love this duck */
  id: string
}

const duckMan: Mallard = {
  id // Intellisense says "I love this duck"
}
Pasted_Image_4_12_19__4_05_PM

I found this out because I'm using graphql-codegen to generate types for my GraphQL schema. It generates types, and the intellisense in some cases repeats many times.

Expectation

I would expect the "closest" comment doc of a type to override all of the others, like it does with an interface. If there's a reason that can't work, then at least having a uniqueness check would be good, maybe new Set(typedocs))

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

Không có tệp nguồn hoặc test nào được nêu tên. Hãy bắt đầu bằng cách tái hiện các ví dụ intersection-type và interface được cung cấp trong TypeScript IntelliSense, sau đó lần theo cách language-service xử lý JSDoc cho các thuộc tính được giao; hoàn tất khi tài liệu của kiểu gần nhất được hiển thị mà không có các comment kế thừa bị trùng lặp.

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
compilers, developer-experience
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
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.