microsoft / microsoft/TypeScript
Diagnostic code 8030 being incorrectly generated using JSDoc `@type` on a function.
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
Diagnostic 8030 is being generated incorrectly when using JSDoc @type on a method when the type is being referred to from an interface. This is using the new tsc LSP - version 7.0.2.
🕗 Version & Regression Information
- This changed between versions 7.0.0-dev.260707.2 and 7.0.2.
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about new native issues being transferred into the main typescript repo.
⏯ Playground Link
No response
💻 Code
// types.ts
interface Example {
method (): number;
}
export {};
// code.js
const exampleFns = {
/**
* @type {Example['method']} // A JSDoc `@type` tag on a function must have a signature with the correct number of arguments.
*/
method () {
return Math.random();
}
};
🙁 Actual behavior
in this example, the diagnostic and LSP info does not tell the user that typescript is internally suffixing | undefined to the type. As such wrapping the type in NonNullable<T> removes the error diagnostic, I do not believe this to be intended behaviour as previous iterations the golang native LSP tsgo (7.0.0-dev.260707.2) did not produce this diagnostic, nor did previous versions of typescript.
🙂 Expected behavior
The type should be properly referenced with no additional suffixing of types, as it used to.
Additional information about the issue
No response
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
Bắt đầu bằng cách tái hiện chẩn đoán với types.ts và code.js bằng TypeScript 7.0.2 được báo cáo và phiên bản trước đó 7.0.0-dev.260707.2. Theo dõi cách tham chiếu JSDoc @type đến Example['method'] được phân giải và lý do | undefined được thêm vào. Hoàn tất khi kiểu method hợp lệ không còn tạo ra chẩn đoán 8030 và có kiểm thử hồi quy cho ví dụ này.
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
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100