microsoft / microsoft/TypeScript

JSDoc : add support for @method (and @property)

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

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

Domain: JavaScript Domain: JSDoc In Discussion 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ả

Search Terms

  • JSDoc
  • @method
  • @property
  • support

Suggestion

It would be great to add support for @method and @property (and maybe @memberof) now that annotations are on their way.

I found bug #15715 that only talks about @property support but I think this makes more sense to see those in a same light because they should have a very common implementation and moreover they meet the same goals as a whole. At least I think and I explain my reasoning about this below!

Use Cases

I have functions that do add methods and/or getters on a class right now, waiting for annotations to get their way in JS/TS. But let's say this: when annotations are here, those 2 flags support will be needed anyway (or at least I think so: I don't see how to make IntelliSense work without those)!

/**
* Some class
 * @class
 */
class Test {
  /* whatever */
}

// this adds a #foo() method on the class prototype as well as a #bar getter(/setter)
someMethodAddingABehavior(Test, ...params);

And tomorrow with annotations:

/**
* Some class
 * @class
 */
@someAnnotationAddingABehavior(...params)
class Test {
  /* whatever */
}

Examples

I'd like to be able to document those doing something like:

/**
 * What foo is doing is great!
 * @method foo
 * @param {string} testParam some testing parameter
 * @returns {string} some random string
 * @memberof Test.prototype
 */
/**
 * Bar is awesome too!
 * @property {number} bar
 * @memberof Test.prototype
 */
someMethodAddingABehavior(Test, ...params);

Or at least to be able to document them in the class itself:

/**
* Some class
 * @class
 */
class Test {
  /* whatever */

  /**
   * What foo is doing is great!
   * @method foo
   * @param {string} testParam some testing parameter
   * @returns {string} some random string
   */
  /**
   * Bar is awesome too!
   * @property {number} bar
   */
}

With support of these, I would expect vscode to suggest to me the foo method and the bar property when completing properties of a value of type Test.

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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 bài kiểm thử nào được nêu tên. Hãy bắt đầu bằng cách xác định phần xử lý chú thích JSDoc hiện có và đường dẫn được sử dụng cho VS Code IntelliSense, sau đó xác định @method và @property nên đóng góp như thế nào vào các thành viên của Test. Được xem là hoàn tất khi các phương thức và thuộc tính bên ngoài đã được tài liệu hóa xuất hiện trong phần hoàn thành mã mà không thay đổi JavaScript được phát ra.

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

Đánh giá

Công nghệ
javascript, typescript, vscode
Lĩnh vực
compilers, 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
30/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.