Skip to main content

.flowconfig [untyped]

The [untyped] section in a .flowconfig file tells Flow to not typecheck files matching the specified regular expressions and instead throw away types and treat modules as any.

This is different from the [ignore] config section that causes matching files to be ignored by the module resolver, which inherently makes them un-typechecked, and also unresolvable by import or require. When ignored, a separate library definition (e.g. via [libs] or flow-typed) must be provided to type any imports from those files, which may not always be desired.

It is also different from the [declarations] section. This also does not typecheck the file contents, but [declarations] does extract and use the signatures of functions, classes, etc, when checking other code.

[untyped] instead causes a file to be ignored by the typechecker as if it had @noflow in it, resolve modules as any type, but allow them to NOT be ignored by the module resolver. Any matching file is parsed but treated as if it had @noflow in it, so its contents are not typechecked and its exports are typed as any, but it can still be require()'d.

Things to keep in mind:

  1. These are OCaml regular expressions.
  2. These regular expressions match against absolute paths. They probably should start with .*

An example [untyped] section might look like:

[untyped]
.*/third_party/.*
.*/src/\(foo\|bar\)/.*
.*\.untyped\.js

This [untyped] section will treat the following files as untyped:

  1. Any file or directory under a directory named third_party
  2. Any file or directory under .*/src/foo or under .*/src/bar
  3. Any file that ends with the extension .untyped.js

You may use the <PROJECT_ROOT> placeholder in your regular expressions. At runtime, Flow will treat the placeholder as if it were the absolute path to the project's root directory. This is useful for writing regular expressions that are relative rather than absolute.

For example, you can write:

[untyped]
<PROJECT_ROOT>/third_party/.*

Which would treat as untyped any file or directory under the directory named third_party/ within the project root. However, unlike the previous example's .*/third_party/.*, it would NOT match files or directories under directories named third_party/, like src/third_party/.

See Also