The method cannot be called by any member of the intersection of the intersection type - Flow | React | Immutable

Announced details:

type IProps = {
  user: ?Map<string, any> & Record<IUser>,
};

Assigning variables from props using destructuring:

const { user } = this.props;
const { name, surname } = user.toJS();   // <---- flow doesn't like this line

uservariable is typeof Map (immutable.js map). Must be used .toJS()to change it to an object. But then a stream error / warning message appears:

Flow: Call of method .toJS().
Method cannot be called on any member of intersection type intersection.

I tried to cope with it myself, failed.

Any help is much appreciated!

+4
source share
1 answer

It has been fixed with:

const { name, surname } = user instanceof Map ? user.toJS() : {};

+1
source

Source: https://habr.com/ru/post/1682659/


All Articles