This preset includes the following plugins:

Example

In

  1. function foo(one: any, two: number, three?): string {}

Out

  1. function foo(one, two, three) {}

Installation

  1. npm install --save-dev @babel/preset-flow

Usage

.babelrc

  1. {
  2. "presets": ["@babel/preset-flow"]
  3. }

Via CLI

  1. babel --presets @babel/preset-flow script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. presets: ["@babel/preset-flow"],
  3. });

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:

  1. f<T>(e)

Would get parsed as a nested binary expression:

  1. f < T > e;

You can read more about configuring preset options here