Skip to content

Class instances flow to interface constraints without validating statics #1704

Closed
@popham

Description

@popham

Given the following, Flow doesn't generate any errors:

interface I {
  static x: number;
  static fn(): number
}

class Impl {
  static x: string;
  static fn(): string {
    return "some string";
  }
};
Impl.x = "another string";

function f(c: I): number {
  return c.constructor.fn();
}

var i = new Impl();
var n: number = f(i);

Flow should flag both members of Impl as incompatible with the corresponding members of I, right? (I stumbled on this when babel 6.5.2--latest npm version--choked on an interface that includes the static "unexpected token" before a static method's signature. Before I open a bug report over there, I want to verify that interfaces are intended to include statics--I asked this over at #803 a while back, but it was never really resolved.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions