It is recommended to use
$ReadOnlyArray instead of an Array or the array shorthand notation.
$ReadOnlyArray is an immutable array collection type and the superclass of array and tuple types in Flow.
All function parameters should have type annotations to get the benefits of type checking. Having proper types for parameters also helps detect wrong function calls with different arguments in the call statement or a different order. It is recommended not to use the
Function type as they don't tell the proper or exact type of the function. Also prefer
(...args: Array<any>) => any over
Function will be deprecated and removed in a future version of Flow.
The use of primitive constructor types such as
String is not preferred.
It is recommended to avoid using weak type annotations
These types can cause the flow type checker to silently skip over portions of your code, which would have otherwise caused type errors. To make full usage and utilize the maximum benefits of type-checking, it is recommended to type each variable, function, object, etc., properly as suggested in the latter description.
It is recommended to make type aliases for all
intersection types. If these are used in raw forms, it might be tempting to copy & paste them around the code. However, this brings source code pollution and unnecessary changes on several parts when these compound types need to be changed. Having a type alias also makes the type reusable without copy-pasting them. This works on the same principle of using a function in any programming language. We create a function that we think needs to be used more than once or make the code more functional and readable.