microsoft / microsoft/TypeScript
Allow `#`-private names in parameter property positions
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
hard privacy https://github.com/microsoft/TypeScript/issues/31670
Suggestion
allow create hard privacy like we do private in constructor(private foo: number)
Use Cases
Examples
allow use constructor(#foo: number) {} or constructor(private #foo: number) {} or constructor(hard private #foo: number) {}
for same as
#foo: number;
constructor(foo: number) {
// This works.
this.#foo = foo;
}
class C {
constructor(#foo: number) {}
log() {
console.dir(this.#foo);
return this
}
}
let o = new C(777).log();
// error
o.#foo;
same as
class C {
#foo: number;
constructor(foo: number) {
// This works.
this.#foo = foo;
}
log() {
console.dir(this.#foo);
return this
}
}
let o = new C(777).log();
// error
o.#foo;
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. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
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
Không có tệp, bài kiểm thử hoặc điểm vào nào được nêu tên. Hãy bắt đầu bằng việc xem xét các dạng tham số constructor được yêu cầu và các ví dụ lớp đi kèm; được xem là hoàn tất khi hỗ trợ cú pháp parameter-property #foo được đề xuất đồng thời giữ nguyên hành vi truy cập private được minh họa.
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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
- 25/100