score:2

Accepted answer

you're creating a sealed object literal with const house = { open: 0 };

check sealed object types from the flow documentation.

try

let house = { };
house.open = 0;
if ( props.door ) {
  house.close = 0;
}

or... you can use object.assign and keep it as a sealed object

const house = object.assign({}, 
  {open: 0},
  props.door ? {close: 0} : null
);

note: flow will not allow you to use

const house = object.assign({}, 
  {open: 0},
  props.door && {close: 0}
);

because props.door && {close: 0} becomes a boolean and flow does not support that


Related Query

More Query from same tag