microsoft / microsoft/TypeScript

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

未关闭
#39,752 1 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Domain: classes
主要语言
Go
星标
111k
派生
14.3k
平均合并
1 天 19 小时
30 天内合并 PR
117

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 TypeScript 3.9.2 Playground 链接开始,将提供的 mixin 示例缩减为一个专注的编译器测试。跟踪抽象属性如何通过 AB 和 AC mixin 的并集进行收集。完成标准是示例报告 ShouldHavePropA 未实现继承的抽象成员 a,并有一个涵盖该行为的回归测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
28/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。