Ale*_*lls 7 abstract-class typescript
我有这个错误:
Class 'Entity' defines instance member property 'method', but extended class '(Anonymous class)' defines it as instance member function
Run Code Online (Sandbox Code Playgroud)
我的代码如下所示:
export abstract class Entity {
abstract method: () => void
}
const e = new (class extends Entity {
method(): void {
return;
}
});
Run Code Online (Sandbox Code Playgroud)
我在github上发现了这个问题,但无法遵循推理: https ://github.com/Microsoft/TypeScript/issues/9722
有人知道这是怎么回事吗?
Ale*_*lls 10
好吧,nvm,这也回答了我的另一个问题:
export abstract class Entity {
abstract method(): void // <--- this needs to be method not (arrow) function
}
const e = new (class extends Entity {
method(): void {
return;
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4797 次 |
| 最近记录: |