How it works…

Why and how does this work? Flow is able to recognize both the /*::  ...  */ and /*:  ...  */ comments, and thus can do its job perfectly well. Since the Flow code is all hidden away in comments, from the point of view of the JS engine, the Flow parts do not even exist, so an obvious advantage of this way of working is that you can directly execute your code.

Why would you not like this? The evident criticism is that the code looks, to put it mildly, ugly. If you were used to, say, TypeScript, having to wrap all type-related things in comments can become a chore, and the code will also be harder to read. Also, there is a risk that you'll mistype a comment (forgetting one of those many colons is a possibility) and then Flow will just ignore your definitions, posing a possible risk of letting a bug go through.

Is there an alternative? Yes, there is, but it will require some extra processing, while giving us the benefit of using standard Flow notation; let's turn to that now. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.16.81