microsoft / microsoft/TypeScript
In JS, there's no way to assert that a property is definitely assigned
Đang mở
@sandersn đang làm issue này rồi.
Từ ngày 6/4/2018.
Domain: JavaScript
Needs Proposal
Suggestion
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
Mô tả
Keywords: JSDoc, Salsa, JavaScript, definite, initialization, initialized, assigned, assertion
class ElementWrapper {
constructor() {
this.init();
}
init() {
this.element = document.createElement('div');
}
getElementStyle() {
this.element.style // error: element is possibly undefined
}
}
We need a way to convince TypeScript in strictNullChecks that this.element is initialized in getElementStyle. Basically a definite initialization assertion.
Related is #23405 which tracks non-null assertions on the expression level.
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.
Đánh giá
Issue này chưa được đánh giá.