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.
The reasoning given in the docs is:
In order to make this safe, Flow would have to mark every single array access as “possibly undefined”.
Flow does not do this because it would be extremely inconvenient to use. You would be forced to refine the type of every value you get when accessing an array.
And here’s an example.