I want to use refinement for a property that can be null. This object with the checked property then passed to function as an argument.
/* @flow */
const a: {+foo: ?string} = {};
const fun = (obj: {+foo: string}) => {
return obj
}
if (a.foo) {
fun(a) // null or undefined [1] is incompatible with string
}
It shouldn't work with an object with mutable property, because this property can be changed to null
later. So that's why I use the immutable property. But it still doesn't work.
Is there a way to pass object with the refined property?