You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tags in a Disjoint Union has to be located at the top level of the object, and can not be nested in another object. Meaning that the following code will not work:
/* @flow */
type FooStyle = {
style: {
width: number,
},
data: {
type: "foo"
}
}
type BarStyle = {
style: {
height: number,
},
data: {
type: "bar"
}
}
type ElementStyle = FooStyle | BarStyle;
function process(ele: ElementStyle) {
if (ele.data.type === "bar") {
// This gives a flow error as height is not found in the object.
console.log(ele.style.height);
}
}
Is there any reason for this? I'm working with a library that limits arbitrary properties to a nested object, so I can't add the tag at top level, and I optimistically thought this would work.
The text was updated successfully, but these errors were encountered:
The tags in a Disjoint Union has to be located at the top level of the object, and can not be nested in another object. Meaning that the following code will not work:
Is there any reason for this? I'm working with a library that limits arbitrary properties to a nested object, so I can't add the tag at top level, and I optimistically thought this would work.
The text was updated successfully, but these errors were encountered: