@babel/preset-flow
This preset includes the following plugins:
Example
In
function foo(one: any, two: number, three?): string {}
Out
function foo(one, two, three) {}
Installation
npm install --save-dev @babel/preset-flow
Usage
With a configuration file (Recommended)
{
"presets": ["@babel/preset-flow"]
}
Via CLI
babel --presets @babel/preset-flow script.js
Via Node API
require("@babel/core").transform("code", {
presets: ["@babel/preset-flow"],
});
Options
all
boolean
, defaults to false
.
Flow will only parse Flow-specific features if a @flow
pragma is present atop the file, or the all
option isset inside the .flowconfig
.
If you are using the all
option in your Flow config, be sure to set this option to true
to get matching behavior.
For example, without either of the above set, the following call expression with a type argument:
f<T>(e)
Would get parsed as a nested binary expression:
f < T > e;
You can read more about configuring preset options here