What is Flow Strict?

Flow Strict

The Strict flag in Flow sets up files for stricter adherence to rules. The user can choose the rules that need to be followed and the files that they apply to.

Usage

@flow strict should be added to the files that are to be checked for Strict rules.

The rules to be adopted by these pages should be written in the .flowconfig files. A [strict] section will be created in these files. This section will then be filled with the Lint Rules needed to be checked for by Flow. Lint Rules are rules defined in Flow that can be checked for when included in .flowconfig files. The following code block shows an example of a .flowconfig file.

[strict]
nonstrict-import
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

The rules in this example are some of the rules that are recommended for use in Flow Strict files.

  1. nonstrict-import shows an error for imports that are not Flow Strict themselves.
  2. unclear-type shows an error when using Object, Function, or any in a type annotation.
  3. unsafe-getters-setters shows an error when getters or setters are used as they can be unsafe.
  4. untyped-import shows an error when an untyped module is being imported.
  5. untyped-type-import shows an error when a type is being imported from an untyped module.
Copyright ©2024 Educative, Inc. All rights reserved