microsoft / microsoft/TypeScript
language service suggestion for Declare property '...' in constructor argument
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
- typescript declare property in constructor
- typescript language service declare property in constructor
Suggestion
When a non-existing property x is accessed on this in a class method, one of the fixes that ts language service currently suggests, is:
Declare property x
Which adds property x to the class.
It would be nice to also have Declare property x in constructor arguments.
It can use private access modifier by default.
Use Cases
While it's generally useful, it becomes especially handy when developing applications with DI frameworks like Angular that use constructor injection to wire dependencies together.
Examples
-
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)
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 với đề xuất hiện có của TypeScript language-service cho “Declare property x” và lần theo điểm vào code-fix cùng các bài kiểm thử của nó, nếu có. Thêm phương án thay thế được yêu cầu để khai báo x trong các đối số của constructor, với private là modifier mặc định, sau đó xác minh đề xuất trong trường hợp class-method được mô tả và kết quả được tạo 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ệ
- typescript
- Lĩnh vực
- devtools
- 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