Flow: New type errors from Immutable.js after upgrading to Flow v0.59

Created on 14 Nov 2017  路  3Comments  路  Source: facebook/flow

I started getting the following error from immutable.js type definitions after upgrading to Flow version 0.59.0. I'm using version 3.8.1 of Immutable.js, and this section had never thrown an error before.

Error: node_modules/immutable/dist/immutable.js.flow:399
399:   static of<T>(...values: T[]): SetSeq<T>;
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. This type is incompatible with
380:   static of<T>(...values: T[]): IndexedSeq<T>;
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type
  This parameter is incompatible:
    399:   static of<T>(...values: T[]): SetSeq<T>;
                                         ^^^^^^^^^ SetSeq. This type is incompatible with
    380:   static of<T>(...values: T[]): IndexedSeq<T>;
                                         ^^^^^^^^^^^^^ IndexedSeq

Most helpful comment

To be clear, this is a regression in flow and intentional according to @vkurchatkin. I would recommend staying on 0.54.1 until the regression is fixed or switch to TypeScript where you're allowed to extend classes without your type checker complaining:

class Flow extends Object {
  static bind() { return new Flow }
  valueOf() { return 'almost none' }
}

All 3 comments

I think you need to create this ticket in immutable.js repo.

@XaveScor I did. But this is a Flow bug. Apparently, Flow no longer allows overriding the method signature of an extended type. This breaks a lot of libraries in the Flow ecosystem like Immutable.

To be clear, this is a regression in flow and intentional according to @vkurchatkin. I would recommend staying on 0.54.1 until the regression is fixed or switch to TypeScript where you're allowed to extend classes without your type checker complaining:

class Flow extends Object {
  static bind() { return new Flow }
  valueOf() { return 'almost none' }
}
Was this page helpful?
0 / 5 - 0 ratings