react-immutable-proptypes icon indicating copy to clipboard operation
react-immutable-proptypes copied to clipboard

.mapOf record fails

Open bdurrer opened this issue 5 years ago • 2 comments

I tried to add our first mapOf test, which failed. While mapOf(ImmutablePropTypes.record) fails, I can pass mapContains with the same data. Yes, I checked wheter there are any non-records in the map - there are none.

Example:

const StackRecord = Record({
    nodeId: null,
}, 'stack');

const myMap = Map(
    ['root', StackRecord({})],
    ['other', StackRecord({})],
    ['more', StackRecord({})],
);


// fails when tested against
ImmutablePropTypes.mapOf(ImmutablePropTypes.record).isRequired,

// passes
ImmutablePropTypes.mapContains({
    root: ImmutablePropTypes.record.isRequired,
}).isRequired

When I put the Records in a List instead, it works fine with listOf(ImmutablePropTypes.record).

It's just mapOf that fails with the following message (library is the name of the property I check). Invalid argument 'library[0]' of type 'array' supplied to 'Nav', expected 'Record'

bdurrer avatar Apr 18 '19 12:04 bdurrer

Here is sample node project, demonstrating the issue. Just run it with node test.js. issue57.zip

bdurrer avatar Apr 23 '19 07:04 bdurrer

This issue is a duplicate of #53, which a few forks already fixed a year ago. Apparently this repo is dead, so if anyone reads this, just replace your dependency with a fork by executing

yarn remove react-immutable-proptypes
yarn add mechanicalchopsticks/react-immutable-proptypes

bdurrer avatar Apr 23 '19 09:04 bdurrer