.flowconfig [untyped]
The [untyped] section in a .flowconfig file tells Flow to not typecheck the
matching files 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.
Flow 0.330 and later
Files are matched with project-relative globs.
Things to keep in mind:
*matches within one directory and**matches across directory boundaries.- Patterns are relative to the project root. Absolute paths and the
<PROJECT_ROOT>placeholder are not supported.
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:
- Any file or directory under a directory named
third_party - Any file or directory under a directory named
src/fooorsrc/bar - Any file that ends with the extension
.untyped.js
To match only a directory at the project root, start the pattern with its name:
[untyped]
third_party/**
This treats as untyped the files under the root third_party/ directory, but
not files under other directories named third_party/, such as
src/third_party/.
Exclusions
Sometimes you may want to treat as untyped all files inside a directory with the exception of a few. An optional prefix "!" which negates the pattern may help. With this, any matching file excluded by a previous pattern will become typechecked again.
[untyped]
third_party/**
!third_party/typed-package-A/**
!third_party/typed-package-B/**
Flow 0.329 and earlier
The following regular-expression syntax works in Flow 0.329 and earlier.
Things to keep in mind:
- These are OCaml regular expressions.
- 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:
- Any file or directory under a directory named
third_party - Any file or directory under
.*/src/fooor under.*/src/bar - 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
.flowconfig [declarations]— a related mode that extracts type signatures without typechecking.flowconfig [ignore]— completely excluding files from Flow's module resolver- Any — the type that untyped modules are treated as