microsoft / microsoft/TypeScript
Provide `declare` keyword support for class methods
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
declare, class, method
Suggestion
I know that declare keyword already support class properties. I've wonder if it is possiable to bring the support to class methods as well?
Use Cases
You override a method a, and there are some other methods that return the return value of a.
Examples
This is just a simple example describing my idea.
class BaseTag
{
constructor(tag: string) {...}
static fromString(tag: string): BaseTag
{
return new BaseTag(tag);
}
static fromNumber(tag: number): BaseTag
{
return this.fromString(tag.toString());
}
}
class ExtendedTag extends BaseTag
{
static fromString(tag: string): ExtendedTag
{
return new BaseTag(`Tag: ${ tag}`);
}
declare static fromNumber(tag: number): ExtendedTag;
// // Without `declare` support
// static fromNumber(tag: number): ExtendedTag
// {
// return super.fromString(tag) as unknown as ExtendedTag;
// }
}
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
Issue không nêu tệp nguồn, bài kiểm thử hoặc điểm vào nào. Hãy bắt đầu bằng cách so sánh hỗ trợ declare hiện có cho các thuộc tính lớp với cú pháp phương thức tĩnh được yêu cầu, đồng thời làm rõ hành vi kiểm tra kiểu và phát mã của nó. Hoàn thành khi ngữ nghĩa của tính năng được đặc tả và được bao phủ bằng các bài kiểm thử.
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
- 35/100