microsoft / microsoft/TypeScript

Generic Type constraint from base classes, interfaces (Pass through)

Đang mở
#28,800 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Awaiting More Feedback Suggestion
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ả

The ability to allow extends type constraint to be an abstract specification of base class, interface.
This also prevent duplication, by having to define the type constraint twice, reduces the need for unnecessary intermediate interfaces.

type ID = string

interface IShape<TID extends ID, Neasted>{
    __ID: TID;
    __Neasted : Neasted
}

interface ITSShape<T, ID>
{
    __tsType: T;
    __ID: ID;
}

interface IShapeType extends IShape<'T', boolean | number | null>
{
}

Not possible

interface IShapeTSType<T extends ['__Neasted']> extends IShapeType
{
    __tsType : T;
}


interface IShapeTSType<T extends ['__Neasted']> extends IShape<'T', boolean | number | string>
{
    __tsType : T;
}


interface IShapeTSType<T extends this['__Neasted']> extends IShapeType
{
    __tsType : T;
}

interface IShapeTSType<T extends TShape['__Neasted'], TShape extends IShapeType> extends TShape
{
    __tsType : T;
}
  • 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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. 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 phân tích các ví dụ IShape, IShapeType và IShapeTSType được đề xuất để làm rõ ngữ nghĩa ràng buộc generic và kế thừa dự kiến. Xác định cú pháp nào nên được chấp nhận và xác minh rằng cú pháp đó tránh các ràng buộc bị trùng lặp mà không thay đổi đầu ra JavaScript; issue không nêu tệp triển khai hoặc bài kiểm thử nào.

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
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.