microsoft / microsoft/TypeScript
Typecheck code blocks in jsdoc
Chưa có ai nhận issue này.
- 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 typecheck
### ✅ Viability Checklist
- [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 isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- [x] This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
### ⭐ Suggestion
When a codeblock is created in jsdoc, apply typechecking on it as if it were part of the code in the file.
### 📃 Motivating Example
I create a method that has a non-trivial function signature (example is contrived)
```ts
type OtherType = { data: TData };
class Class {
doSomething(arg: OtherType): void;
}
```
I would like to document the idiomatic usage in jsdoc
```ts
/**
* Does something, example:
* ```ts
* const cls = new Class<{ x: number }>();
* cls.doSomething({ data: { x: 1, y: 2 } });
* ```
*/
```
If the function signature or underlying types change in any way, the typechecker will tell me to update the usages, but not the example.
The example becomes outdated potentially unknowingly, potentially causing bad code that could have been prevented if the example was typechecked.
### 💻 Use Cases
1. What do you want to use this for?
Typecheck code blocks in jsdoc
2. What shortcomings exist with current approaches?
Relying on implementations as the idiomatic way when the example in the jsdoc is intended the be the idiomatic way.
3. What workarounds are you using in the meantime?
Inspection
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Không có tệp, bài kiểm thử hoặc điểm truy cập nào được nêu tên. Việc nghiên cứu cần xác định các khối mã JSDoc và các điểm truy cập kiểm tra kiểu, sau đó định nghĩa các bài kiểm thử cho thấy các ví dụ được kiểm tra dựa trên các khai báo xung quanh 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
- Lĩnh vực
- compilers, documentation
- 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