Flow: Flow does not catch interface incompatibility

Created on 19 Apr 2017  路  1Comment  路  Source: facebook/flow

Here is a simplified example to reproduce the issue, also inlined below for convenience:

// @flow

export interface Continue <a, b> {
  continue(ok:a):b
}

class Chain <a, b> {
  handler:Continue<a, b>
  constructor(handler:Continue<a, b>) {
    this.handler = handler
  }
}

class Then <a, b> {
  continue:(input:a) => b
  toFrame():Chain<a, b> {
    return new Chain(this.continue) // <- should be an error here!!
  }
}

Flow does not catches an error that I have introduced when I modified an interface of Chain class from taking a function to continue to an object with method continue.

It is also worth mentioning that if I change Continue to be a type flow reports an error as expected, which I found surprising. Unfortunately I to use implements Continue<a, b> it needs to be an interface.

interfaces bug

Most helpful comment

Simpler example:

interface T1 {
  foo: string;
}

type T2 = {
  foo: string;
}

var a: T1 = (() => {}: () => void); // no error
var b: T2 = (() => {}: () => void); // error

>All comments

Simpler example:

interface T1 {
  foo: string;
}

type T2 = {
  foo: string;
}

var a: T1 = (() => {}: () => void); // no error
var b: T2 = (() => {}: () => void); // error
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mmollaverdi picture mmollaverdi  路  3Comments

philikon picture philikon  路  3Comments

cubika picture cubika  路  3Comments

funtaps picture funtaps  路  3Comments

l2silver picture l2silver  路  3Comments