microsoft / microsoft/TypeScript
Poor error recovery when `enum` is used as a parameter name
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ả
TypeScript Version: 3.6.2
Search Terms: expression expected reserved word
Code
function converter<Enum>(values: string[], enums: Enum[]): Map<Enum, string> {
return new Map<Enum, string>(
enums.map((enum: Enum, index: number) => [ enum, values[index] ])
);
}
Expected behavior:
After some confusion why this displays so many red curlies, the error should make it clear to me that the reserved word enum is accidentaly being used as an argument name. An error is given on enum saying something along the lines of You cannot use enum as a variable/argument because it is a reserved word.
Actual behavior:
After a LOT of confusion, one realizes that the reserved word enum is accidentally being used as an argument name. An error is given on several parts in the above code, where the most helpful one is Expression expected (ts1109), which is just unnecesarily confusing.
Related Issues:
None that seem related.
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
Tái hiện chẩn đoán bằng mã được cung cấp trong TypeScript 3.6.2 Playground, sau đó so sánh các lỗi của parser xung quanh tên tham số enum. Cải thiện lỗi được báo cáo để xác định việc sử dụng sai từ dành riêng mà không tạo ra các chẩn đoán dây chuyền gây khó hiểu, rồi kiểm tra kết quả với cùng ví dụ đó.
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
- 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
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 42/100