Closed
Description
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
Labels
No labels