Facebook is releasing an early version of its open-source static type checker for JavaScript. Flow is designed to advance developer productivity and ensure code quality with features such as early error checking and code intelligence, according to the company.
“Facebook loves JavaScript; it’s fast, it’s expressive, and it runs everywhere, which makes it a great language for building products. At the same time, the lack of static typing often slows developers down,” the company wrote on its blog. “We have designed Flow so developers can reap its benefits without losing the ‘feel’ of coding in JavaScript.”
Developers can use Flow to catch common flaws found in JavaScript programs without having to make any changes to their code, and can also identify invariants in their code to have them automatically maintained, according to Facebook. Its type checking is opt-in, meaning it won’t type check a developers code unless specified.
“This means that you can gradually convert your JavaScript codebase to Flow while reaping incremental benefits,” Facebook wrote. “When you do opt in a file, Flow tries to type check the code automatically by performing type inference, reporting errors without further manual guidance.”
Flow’s type checking is also online, meaning it “performs an initial analysis of all files in a codebase, and then monitors those files for subsequent changes, type checking them and other dependencies proactively in the background,” according to the website.
Flow is still a work in progress and will continue to be developed by Facebook in the upcoming months. Some features the company plans on adding include ES6 module support, editor integration for Flow type errors, Flow commands to support IDEs, and error message categorization.
“In addition to working on Facebook-scale codebases, we hope that the implementation of Flow’s analysis engine will be useful to those building similar development tools for JavaScript and other languages,” the company wrote.
More information is available here.