如何让流程正确检查类型实现的接口?

时间:2016-06-21 02:27:51

标签: javascript flowtype

我的流代码看起来像这样。当我flow check时收到错误1: const docs: Array<LeadDoc> = property docType of LeadDoc. Property not found in

流程中是否尚未支持此功能?

export interface LeadDoc {
  docType(): string;
}

class Foo {
  docType(): string {
    return 'foo';
  }
}

const docs: Array<LeadDoc> = [
  Foo,
];

1 个答案:

答案 0 :(得分:1)

docTypeFoo实例的属性,但[Foo]是{{>>的静态的单例数组1}}。 Foo的类型为[new Foo]