需要使用$ Subtype和泛型键入函数

时间:2018-08-06 13:55:14

标签: javascript flowtype

我正在尝试使用$Subtype来键入mixin函数。我相信我的类型签名是正确的。我不断收到一些错误:

const MyMixin: MixinFunction = superclass => class extends superclass {};
                                             ^ Cannot extend `superclass` [1] with
                                               `<<anonymous class>>` because `A` [2] is
                                               not inheritable.

这是我的超级简单代码(on Try Flow):

type MixinFunction = <A>(superclass: Class<A>) => Class<$Subtype<A>>;

const MyMixin: MixinFunction = superclass => class extends superclass {};

如何使此代码正常运行?

0 个答案:

没有答案