Immutable-js: Record flow declaration does not follow Map

Created on 22 Oct 2016  路  4Comments  路  Source: immutable-js/immutable-js

It seems that the Record type is completely under documented. Both in the documentation and flow files.

Since the Record type is an extension of the Map type (contains getIn, hashCode, etc.) I think this should be better documented to avoid confusion.

Most helpful comment

Will be fixed in the upcoming release

All 4 comments

I've run into this as well when using Flow. I've yet to find a good way of typing immutable objects the same way one can type the shape of plain JS objects.

@iansinnott Immutable.Record (as opposed to Immutable.Map) is completely describable by Flow.

type MyRecord = Immutable.Record<{ id: number, name: string }>;

const MyRecord = Immutable.Record({ id: 0, name: undefined });

The problem is that while the Immutable declaration declares it as an Immutable.Record type it doesn't extend the Map type.

Yeah I think we're talking about the same thing. It becomes an issue because although the shape of the record is typed it doesn't have the get, getIn, etc, methods which one usually uses. So flow ends up throwing invalid errors.

Will be fixed in the upcoming release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

colbyr picture colbyr  路  3Comments

Anahkiasen picture Anahkiasen  路  3Comments

chandlerprall picture chandlerprall  路  3Comments

jbonta picture jbonta  路  3Comments

coodoo picture coodoo  路  3Comments