Home > Web Front-end > JS Tutorial > Introduction to JavaScript static type checking tool FLOW_Basic knowledge

Introduction to JavaScript static type checking tool FLOW_Basic knowledge

WBOY
Release: 2016-05-16 16:22:02
Original
1386 people have browsed it

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 license.

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 reference and other issues.
At the same time, Flow adds static type syntax identifiers to JavaScript, so that developers can clarify the types in the code and have them automatically maintained by Flow.
Currently, Flow has the following two features:

1. Flow’s type checking is optional

Unless you explicitly tell Flow that it needs to type check certain files, it will not check files that you don’t need to check. This means that you can slowly migrate your codebase to Flow and continue to reap its growing value.
For example, if you select a file to check, Flow will automatically type-check your code and find errors in your code. However, if your code is very detailed and exists in different files, this approach may be too cumbersome. But sometimes, if you choose to check some very large libraries, Flow may not be so accurate. In this case, we can manually use "type annotations" or switch to "weak mode" to limit its type reference to solve the problem.

2. Flow’s type checking is online

When checking the code base, Flow will do a preliminary analysis of it, and then perform continuous monitoring, type checking, and dependency checking on subsequent changes in the background. For developers, it means that they don’t need to spend a lot of time compiling. When saving files in batches, Flow's type check will be automatically triggered and the results will be persisted for reuse.

Usage 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 having to compromise 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 safely. Choosing open source in the early stage also hopes to give Flow a chance to quickly grow in front of all developers.

Next, I will talk about some examples to help you quickly understand how Flow works and how Flow can help us work better.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template