PropTypes and Flow cover similar things but are using different approaches. PropTypes can give you warnings during runtime, which can be helpful to quickly find malformed responses coming from a server, etc. However, Flow seems to be the future and with concepts like generics is a very flexible solution. Also the autocompletion offered by Nuclide is a big plus for Flow.
My question now is which is the best way to go, when starting a new project. Or could it be a good solution to use both, Flow and PropTypes? The problem with using both is that you write a lot of duplicate code. This is an example of a music player app I wrote:
export const PlaylistPropType = PropTypes.shape({
next: ItemPropTypes,
current: ItemPropTypes,
history: PropTypes.arrayOf(ItemPropTypes).isRequired
});
export type Playlist = {
next: Item,
current: Item,
history: Array<Item>
};
Both definitions basically contain the same information and when the data type is changed, both definitions need to be updated.
I found this babel plugin to convert type declarations to PropTypes, which might be a solution.