Flow is a static type checking tool for JavaScript that is produced by Facebook. Its code is hosted on top of GitHub and is compliant with the BSD open source protocol.
About Flow
It can help us catch common bugs in JavaScript development without needing to modify your original code, such as static type conversion, null reference, and so on.
At the same time, Flow adds a static type of syntax identifier to JavaScript so that the developer can identify the type in the code and let it be automatically maintained by the flow.
Currently, flow has the following two characteristics:
1. Flow type check is optional
Unless you explicitly tell the flow that a type check is required for certain files, it does not check that you do not need to check the file. This means that you can slowly transfer your code base to flow and continue to reap the value of its continued growth.
For example, if you select a file to check, flow automatically checks the type of your code and detects errors in your code. However, if your code is finely divided into different files, it is too cumbersome. But sometimes you choose to check out some very large libraries, and the flow may not be that accurate. In this case, we can manually use the type annotation or switch to weak mode to limit its type reference to solve the problem.
2. The type check of flow is online
When you check the code base, flow makes a preliminary analysis of it, and then it keeps monitoring, type checking, and dependency checking for subsequent changes in the background. For developers, it means that there is no need to spend a lot of time on compilation. When you save the file in bulk, the type check of the flow is triggered automatically, and the results are persisted for reuse.
Use and expectations
Flow is a new library produced by Facebook, with a lot of features still in the process of development. Its long-term goal is to make JavaScript
Development experience to be better without compromising the most essential things in the language. We want developers to have powerful tools to understand how to maintain their code and to reuse and optimize their code more easily and securely. Early choice of open source, but also hope to give flow an opportunity to quickly grow up in front of all developers.
Next, I'll go over some examples to help you get a quick idea of how flow works and how to make it work better through flow.