December 2018
Intermediate to advanced
642 pages
15h 5m
English
It so happens that Flow provides two ways of specifying types: the way that we have been using so far, with extra type notations, and another more verbose one, through the comments. Of course, JS doesn't know about type definitions, so the first style won't work unless we do extra work (as we'll see) but using comments is totally safe.
To define types with comments, all Flow specific definitions must be enclosed in comments starting with /*: (note the extra colon) and finishing with the usual */, for simple basic types, or /*:: and */ for everything else. We can revisit some examples we saw earlier in Chapter 2, Using JavaScript Modern Features. Simple cases are as follows:
// Source file: src/flowcomments.jslet someFlag ...
Read now
Unlock full access