Flow is a static type checking tool for JavaScript produced by Facebook. Its code is hosted on github and complies with the BSD open source protocol.
About Flow
It can help us catch common errors in JavaScript development without additionally modifying your original code, such as static type conversion, null value references, etc.
At the same time, Flow adds static typed syntax identifiers to JavaScript, so developers can clarify the types in the code and make them automatically maintained by Flow.
Currently, Flow has the following two characteristics:
1. Flow's type check is optional
Unless you explicitly tell Flow that you need to type check certain files, it won't check the files you don't need to check. That said, you can slowly transfer your code base to Flow and continue to reap its continued growth value.
For example, if you choose a file to check, Flow will automatically check the type of your code and find out errors in your code. However, if your code is divided very carefully and exists in different files, this approach seems too cumbersome. But sometimes, if you choose to check some very large libraries, Flow may not be that accurate. In this case, we can manually use "type annotation" or switch to "weak mode" to restrict its type references to solve the problem.
2. Flow's type check is online
When checking the code base, Flow will conduct a preliminary analysis of it, and then conduct continuous monitoring, type checking, and dependency checking on subsequent changes in the background. For developers, it means that there is no need to spend a lot of time on compiling. When saving files in batches, the type check of Flow will be automatically triggered, and the results will be persisted for reuse.
Use and Expectations
Flow is a new library produced by Facebook, and a large number of features are still under development. Its long-term goal is to make JavaScript
The development experience becomes 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 reuse and optimize their code more conveniently and safely. In the early stage of choosing open source, I also hope to give Flow a chance to grow up quickly in front of all developers.
Next, I will talk about some examples to help you quickly understand how Flow works and how to make us work better through Flow.