sheki
sheki

Reputation: 9370

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

Is this not yet supported in flow?

export interface LeadDoc {
  docType(): string;
}

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

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

Upvotes: 0

Views: 94

Answers (1)

Sam Goldman
Sam Goldman

Reputation: 1446

docType is a property of instances of Foo, but [Foo] is the singleton array of the statics of Foo. [new Foo] is of the type Array<LeadDoc>.

Upvotes: 1

Related Questions