Flow Cookbook

Gotchas and interesting cases of flow issues
Gotchas and interesting cases of flow issues
This is a platform for User Generated Content. G/O Media assumes no liability for content posted by Kinja users to this platform.

Advertisement

Nov 4
Save
Flexible type as returned value

Imagine a simple a Radio component, what returned its passed value prop on mouse click. It’s easily typable as a string, and flow won’t complain about it.
But what about if we wrap this component into an other where we dinamically create these radio components with mapping through a union typed Array.

Oct 14
1

As it turns out, when you try to access an element in an array, flow will give you no errors, even though the given index might be out of bounds for the array. So accessing an element of Array<T> will always be of type T, and you need to remember yourself to check its existence.

Oct 3
Save
The power of exact object types

Zoli recently implemented a new Blocknode, called DeletedEmbed, which we display in place of embeds that have been deprecated. We have a subset of Blocknodes called FeaturedMedia, consisting of a bunch of image / video nodes, and now the new DeletedEmbed. Some issues arose from this addition though. The root cause of

Advertisement

Oct 3
Save
Array.filter and type narrowing

When you have an array of BlockNodes, it would be understandable if you wanted to filter said array to get a list of a specific node, KinjaVideo for example. Flow doesn’t support that, unfortunately.

Oct 3
Save
Type Refinement Invalidation

Lately a couple of backend developers started touching javascript code and more of them ran into the issue of type refinement invalidation. It’s probably something that doesn’t really happen in Scala, but someone can enlighten me about it. This is what happens:

Advertisement