Skip to content

Instantly share code, notes, and snippets.

@sverrejoh
Created June 4, 2016 17:04
Show Gist options
  • Select an option

  • Save sverrejoh/81fe3a521ea3de2193ef1212d310d623 to your computer and use it in GitHub Desktop.

Select an option

Save sverrejoh/81fe3a521ea3de2193ef1212d310d623 to your computer and use it in GitHub Desktop.
/* @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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment