简体   繁体   English

如何获得流程以正确检查类型所实现的接口?

[英]How do I get flow to correctly check the interface being implemented by a type?

I have flow code which looks like this. 我有看起来像这样的流程代码。 When I flow check I get an error 1: const docs: Array<LeadDoc> = property docType of LeadDoc. Property not found in 当我进行flow check ,出现错误1: const docs: Array<LeadDoc> = property docType of LeadDoc. Property not found in 1: const docs: Array<LeadDoc> = property docType of LeadDoc. Property not found in

Is this not yet supported in flow? 流程中尚不支持此功能吗?

export interface LeadDoc {
  docType(): string;
}

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

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

docType is a property of instances of Foo , but [Foo] is the singleton array of the statics of Foo . docTypeFoo 实例的属性,但是[Foo]Foo 静态元素的单例数组。 [new Foo] is of the type Array<LeadDoc> . [new Foo]的类型为Array<LeadDoc>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM