8000 Strange Flow Error v4.0.0-rc.9 · Issue #1442 · immutable-js/immutable-js · GitHub
[go: up one dir, main page]

Skip to content
Strange Flow Error v4.0.0-rc.9 #1442
Closed
Closed
@bbar

Description

@bbar

Can anyone explain why flow is throwing an error for the following code?

// @flow
import { Record } from 'immutable';
import type { RecordFactory, RecordOf } from 'immutable';

// Types
type FirstProps = {
  a: number,
};
type First = RecordOf<FirstProps>;

type SecondProps = {
  b: number,
};
type Second = RecordOf<SecondProps>;

type RootProps = {
  first: First,
  second: Second,
}
type Root = RecordOf<RootProps>;

type StateProps = {
  root: Root,
};
type State = RecordOf<StateProps>;

// Factories
const makeFirst: RecordFactory<FirstProps> = Record({
  a: 1,
});

const makeSecond: RecordFactory<SecondProps> = Record({
  b: 1,
});

const makeRoot: RecordFactory<RootProps> = Record({
  first: makeFirst(),
  second: makeSecond(),
});

const makeState: RecordFactory<StateProps> = Record({
  root: makeRoot(),
});

const state = makeState();

const fails = state
  .setIn(['root', 'first', 'a'], -1)
  .setIn(['root', 'second', 'b'], -1);

Flow throws the following error:

call of method `setIn`
Method cannot be called on any member of intersection type
intersection
: src/shared-redux/location/flow-test.js:47
Member 1:
type application of class `RecordInstance`
: node_modules/immutable/dist/immutable.js.flow:1379
Error:
call of method `setIn`
: src/shared-redux/location/flow-test.js:47
Method cannot be called on any member of intersection type
intersection
: src/shared-redux/location/flow-test.js:47
Member 1:
`this` type
: node_modules/immutable/dist/immutable.js.flow:1439
Error:
call of method `setIn`
: src/shared-redux/location/flow-test.js:47
Function cannot be called on any member of intersection type
intersection
: src/shared-redux/location/flow-test.js:47
Member 2:
type parameter `T` of call of method `setIn`
: src/shared-redux/location/flow-test.js:47
Error:
property `setIn`
: src/shared-redux/location/flow-test.js:49
Property not found in
object type
: src/shared-redux/location/flow-test.js:41
Member 2:
type parameter `Values` of call of method `setIn`
: src/shared-redux/location/flow-test.js:47
Error:
property `setIn`
: src/shared-redux/location/flow-test.js:48
Property not found in
object type
: src/shared-redux/location/flow-test.js:41

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0