IntelliJ IDEA 2017.3 Help

Flow

This feature is only supported in the Ultimate edition.

IntelliJ IDEA provides basic support of Flow static type checker that brings type annotations to JavaScript. This support involves recognition and syntax highlighting of Flow structures on all operating systems.

Before you start

  1. Download and install the Node.js runtime environment.
  2. Configure the Node.js interpreter in IntelliJ IDEA as described in Configuring a local Node.js interpreter.
  3. Install and enable the NodeJS repository plugin as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.

Installing Flow

Open the built-in IntelliJ IDEA Terminal (Alt+F12) and at the command prompt, type:

  • npm install --global flow-bin to install Flow globally.
  • npm install --save-dev flow-bin to install Flow in the current project.

Configuring Flow in IntelliJ IDEA

To have IntelliJ IDEA recognize Flow structures, provide correct syntax highlighting, report errors properly, and avoid false-positive error highlighting, change the JavaScript language level to Flow, add a .flowconfig configuration file to your project, and supply every file to be checked with a // @flow comment on top.

To change the language level to Flow

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), click JavaScript under Languages and Frameworks. The JavaScript page opens.
  2. From the JavaScript Language Version drop-down list, choose Flow.
  3. In the Flow package or executable field, specify the path to the node_modules\flow-bin package or the Flow binary executable file. To use node_modules\.bin\flow make sure the path to Node.js is added to the PATH environment variable.
  4. In the Use Flow server for: area, specify the basis for coding assistance by selecting or clearing the following checkboxes:
    • Type checking: When this checkbox is selected, syntax and error highlighting is provided based on the data received from the Flow server. When the checkbox is cleared, only the basic internal IntelliJ IDEA highlighting is available.
    • Navigation, code completion, and type hinting: When this checkbox is selected, suggestion lists for reference resolution and code completiong contain both suggestions retrieved from integration with Flow and suggestions calculated by IntelliJ IDEA. When the checkbox is cleared, references are resolved through IntelliJ IDEA calculation only.
    The checkboxes are available only when the path to the Flow executable file is specified.
  5. Keep the Save all modified files automatically checkbox selected to ensure that Flow is applied continuously because Flow checks the current files only after all the other modified files are saved.

To generate a .flowconfig configuration file in your project
open the embedded Terminal (View | Tool Windows | Terminal) and type flow init at the command prompt.

To have a file checked with Flow
Add a // @flow comment at the top of it: just type flow, press Tab, and IntelliJ IDEA will expand it into // @flow.

Last modified: 12 December 2017

See Also

Language and Framework-Specific Guidelines: