microsoft / microsoft/TypeScript
Dead return statements in a generator should offer a did-you-mean-yield codefix
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.4k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
Mô tả
TypeScript Version: 3.0.0-dev.201xxxxx
Search Terms: yield return generator
Currently it is possible to have the following code:
Code
async function *myGeneratorFunction(): AsyncIterableIterator<number> {
return 1;
return 2;
return 3;
}
Expected behavior:
A generator function that yields numbers 1 - 3
Actual behavior:
No syntax/runtime error but due to a human mistake the generator function is useless.
I copy/pasted an existing generator function, deleted the body with the new implementation and mistakenly used return instead of yield.
It would be nice if TypeScript could warn when it's encountering a return with an actual value inside a generator function.
It makes no sense to return a value.
Could be combined with a codefix in the IDE: Did you mean yield?
Playground Link:
Related Issues:
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 ví dụ async generator từ issue và kiểm tra cách compiler và language-service xử lý các câu lệnh return trong generators. Công việc hoàn tất khi một return có giá trị trong generator tạo ra cảnh báo như mong đợi và IDE cung cấp codefix “Did you mean yield?”, kèm theo coverage cho hành vi của 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
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 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