microsoft / microsoft/TypeScript

Mixin abstract class: union of abstract propeties is not abstract.

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

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

Bug Domain: classes
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ả

TypeScript Version: 3.9.2

Search Terms: mixin abstract union

Expected behavior:
Union of abstract propeties is abstract property.

Actual behavior:
Union of abstract propeties is not abstract.

Related Issues:

Code

type Constructor = new (...args: any[]) => {};

class BaseClass {}

function AB<TBase extends Constructor>(Base: TBase) {
  abstract class AB extends Base {
    abstract a: number
    abstract b: number
  };
  return AB
}
function AC<TBase extends Constructor>(Base: TBase) {
  abstract class AC extends Base {
    abstract a: number
    abstract c: number
  };
  return AC
}

// should throw "Non-abstract class 'ShouldHavePropA' does not implement inherited abstract member 'a' from class ..."
class ShouldHavePropA extends AB(AC(BaseClass)) { 
    b = 1;
    c = 2;
}
Output
"use strict";
class BaseClass {
}
function AB(Base) {
    class AB extends Base {
    }
    ;
    return AB;
}
function AC(Base) {
    class AC extends Base {
    }
    ;
    return AC;
}
class ShouldHavePropA extends AB(AC(BaseClass)) {
    constructor() {
        super(...arguments);
        this.b = 1;
        this.c = 2;
    }
}

Compiler Options
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "declaration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "moduleResolution": 2,
    "target": "ES2017",
    "jsx": "React",
    "module": "ESNext"
  }
}

Playground Link: Provided

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 với liên kết TypeScript 3.9.2 Playground và rút gọn ví dụ mixin được cung cấp thành một bài kiểm thử compiler tập trung. Theo dõi cách các thuộc tính abstract được thu thập thông qua hợp của các mixin AB và AC. Hoàn tất khi ví dụ báo rằng ShouldHavePropA không triển khai abstract member a được kế thừa, với một regression test bao quát hành vi này.

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
Lỗi
Độ 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
28/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.