.flowconfig [options]
.flowconfig
文件中的 [options]
部分可以包含多个以下形式的键值对:
¥The [options]
section in a .flowconfig
file can contain several key-value
pairs of the form:
[options]
keyA=valueA
keyB=valueB
任何被省略的选项都将使用它们的默认值。某些选项可以用命令行标志覆盖。
¥Any options that are omitted will use their default values. Some options can be overridden with command line flags.
可用选项
¥Available options
all
类型:boolean
¥Type: boolean
将其设置为 true
以检查所有文件,而不仅仅是那些带有 @flow
的文件。
¥Set this to true
to check all files, not just those with @flow
.
all
的默认值为 false
。
¥The default value for all
is false
.
autoimports
≥0.143.0{#toc-autoimports}
类型:boolean
¥Type: boolean
启用后,IDE 自动补齐建议导出其他文件,并自动插入必要的 import
语句。还针对未定义的变量提供了 "快速解决" 代码操作,建议匹配导入。
¥When enabled, IDE autocomplete suggests the exports of other files, and the necessary import
statements are automatically inserted. A "quick fix" code action is also provided on undefined variables that suggests matching imports.
从 Flow v0.155.0 开始,autoimports
的默认值为 true
。
¥The default value for autoimports
is true
as of Flow v0.155.0.
babel_loose_array_spread
类型:boolean
¥Type: boolean
将其设置为 true
以检查数组扩展语法是否仅用于数组,而不是任意可迭代对象(例如 Map
或 Set
)。如果你在 宽松模式 中使用 Babel 转换代码,这会在运行时做出不符合规范的假设,这非常有用。
¥Set this to true
to check that array spread syntax is only used with arrays, not arbitrary iterables (such as Map
or Set
). This is useful if you transform your code with Babel in loose mode which makes this non-spec-compliant assumption at runtime.
例如:
¥For example:
const set = new Set();
const values = [...set]; // Valid ES2015, but Set is not compatible with $ReadOnlyArray in Babel loose mode
babel_loose_array_spread
的默认值为 false
。
¥The default value for babel_loose_array_spread
is false
.
emoji
类型:boolean
¥Type: boolean
将其设置为 true
可将表情符号添加到 Flow 在忙于检查项目时输出的状态消息中。
¥Set this to true
to add emoji to the status messages that Flow
outputs when it's busy checking your project.
emoji
的默认值为 false
。
¥The default value for emoji
is false
.
enums
类型:boolean
¥Type: boolean
将其设置为 true
以启用 Flow 枚举。除了启用 .flowconfig
选项之外,还需要 附加步骤。
¥Set this to true
to enable Flow Enums.
Additional steps are required beyond just enabling the .flowconfig
option.
enums
的默认值为 false
。
¥The default value for enums
is false
.
exact_by_default
类型:boolean
¥Type: boolean
当设置为 true
(从版本 0.202 开始的默认值)时,Flow 默认将对象类型解释为精确的:
¥When set to true
(the default as of version 0.202), Flow interprets object types as exact by default:
1type O1 = {foo: number} // exact2type O2 = {| foo: number |} // exact3type O3 = {foo: number, ...} // inexact
当该标志为 false
时,Flow 具有以下行为:
¥When this flag is false
, Flow has the following behavior:
1type O1 = {foo: number} // inexact2type O2 = {| foo: number |} // exact3type O3 = {foo: number, ...} // inexact
从 Flow 版本 0.199 开始,该标志的默认值为
false
。¥From inception to Flow version 0.199, the default value of the flag was
false
.在版本 0.200 和 0.201 中,该标志需要显式设置为
true
或false
。¥In versions 0.200 and 0.201, the flag was required to be explicitly set to either
true
orfalse
.从 0.202 版本开始,默认值为
true
。¥From version 0.202, the default value is
true
.
你可以在我们关于制作 默认情况下按对象类型精确,默认情况下 的博客文章中了解有关此更改的更多信息。
¥You can read more about this change in our blog post about making exact by object types by default, by default.
experimental.const_params
类型:boolean
¥Type: boolean
将其设置为 true
会使 Flow 将所有函数参数视为 const 绑定。重新分配参数是一个错误,它让 Flow 在改进方面不那么保守。
¥Setting this to true
makes Flow treat all function parameters as const
bindings. Reassigning a param is an error which lets Flow be less conservative
with refinements.
默认值为 false
。
¥The default value is false
.
include_warnings
类型:boolean
¥Type: boolean
将其设置为 true
会使 Flow 命令在错误输出中包含警告。默认情况下,警告在 CLI 中隐藏,以避免控制台溢出。(IDE 是显示警告的更好界面。)
¥Setting this to true
makes Flow commands include warnings in the error output.
Warnings are hidden by default in the CLI to avoid console spew. (An IDE is a
much better interface to show warnings.)
默认值为 false
。
¥The default value is false
.
lazy_mode
类型:boolean
¥Type: boolean
有关惰性模式的更多信息,请参阅 惰性模式文档。
¥For more on lazy modes, see the lazy modes docs.
在 .flowconfig
中设置 lazy_mode
将导致该根的新 Flow 服务器使用惰性模式(如果设置为 false
,则不使用惰性模式)。可以使用 --lazy-mode
标志从 CLI 覆盖此选项。
¥Setting lazy_mode
in the .flowconfig
will cause new Flow servers for that
root to use lazy mode (or no lazy mode if set to false
). This option can
be overridden from the CLI using the --lazy-mode
flag.
默认值为 false
。
¥The default value is false
.
max_header_tokens
类型:integer
¥Type: integer
Flow 尝试避免解析非 Flow 文件。这意味着 Flow 需要开始对文件进行词法分析以查看其中是否包含 @flow
或 @noflow
。此选项允许你配置在确定没有相关文档块之前文件 Flow 词法的数量。
¥Flow tries to avoid parsing non-flow files. This means Flow needs to
start lexing a file to see if it has @flow
or @noflow
in it. This option
lets you configure how much of the file Flow lexes before it decides there is
no relevant docblock.
既不是
@flow
也不是@noflow
- 使用不允许的 Flow 语法解析此文件,并且不对其进行类型检查。¥Neither
@flow
nor@noflow
- Parse this file with Flow syntax disallowed and do not typecheck it.@flow
- 使用允许的 Flow 语法解析此文件并对其进行类型检查。¥
@flow
- Parse this file with Flow syntax allowed and typecheck it.@noflow
- 使用允许的 Flow 语法解析此文件,并且不对其进行类型检查。这意味着作为一个应急方案,可以抑制文件中的 Flow,而不必删除所有特定于 Flow 的语法。¥
@noflow
- Parse this file with Flow syntax allowed and do not typecheck it. This is meant as an escape hatch to suppress Flow in a file without having to delete all the Flow-specific syntax.
max_header_tokens
的默认值为 10。
¥The default value of max_header_tokens
is 10.
module.file_ext
默认情况下,Flow 将查找扩展名为 .js
、.jsx
、.mjs
、.cjs
和 .json
的文件。你可以使用此选项覆盖此行为。
¥By default, Flow will look for files with the extensions .js
, .jsx
, .mjs
,
.cjs
and .json
. You can override this behavior with this option.
例如,如果你这样做:
¥For example, if you do:
[options]
module.file_ext=.foo
module.file_ext=.bar
然后 Flow 将查找文件扩展名 .foo
和 .bar
。
¥Then Flow will instead look for the file extensions .foo
and .bar
.
注意:你可以多次指定
module.file_ext
¥Note: you can specify
module.file_ext
multiple times
module.ignore_non_literal_requires
类型:boolean
¥Type: boolean
将其设置为 true
,当你将 require()
与字符串字面量以外的其他内容一起使用时,Flow 将不再诉说。
¥Set this to true
and Flow will no longer complain when you use require()
with something other than a string literal.
默认值为 false
。
¥The default value is false
.
module.name_mapper
类型:regex -> string
¥Type: regex -> string
指定与模块名称匹配的正则表达式和替换模式,以 ->
分隔。
¥Specify a regular expression to match against module names, and a replacement
pattern, separated by a ->
.
例如:
¥For example:
module.name_mapper='^image![a-zA-Z0-9$_]+$' -> 'ImageStub'
这使得 Flow 将 require('image!foo.jpg')
视为 require('ImageStub')
。
¥This makes Flow treat require('image!foo.jpg')
as if it were
require('ImageStub')
.
这些是 OCaml 正则表达式。使用 \(
和 \)
(需要斜杠!)创建一个捕获组,你可以在替换模式中将其引用为 \1
(最多 \9
)。
¥These are OCaml regular expressions.
Use \(
and \)
(slashes required!) to create a capturing group, which you
can refer to in the replacement pattern as \1
(up to \9
).
注意:你可以多次指定
module.name_mapper
¥Note: you can specify
module.name_mapper
multiple times
module.name_mapper.extension
类型:string -> string
¥Type: string -> string
指定要匹配的文件扩展名和替换模块名称,以 ->
分隔。
¥Specify a file extension to match, and a replacement module name, separated by
a ->
.
注意:这只是
module.name_mapper='^\(.*\)\.EXTENSION$' -> 'TEMPLATE'
的简写)¥Note: This is just shorthand for
module.name_mapper='^\(.*\)\.EXTENSION$' -> 'TEMPLATE'
)
例如:
¥For example:
module.name_mapper.extension='css' -> '<PROJECT_ROOT>/CSSFlowStub.js.flow'
使 Flow 将 require('foo.css')
视为 require(PROJECT_ROOT + '/CSSFlowStub')
。
¥Makes Flow treat require('foo.css')
as if it were
require(PROJECT_ROOT + '/CSSFlowStub')
.
注意:你可以为不同的扩展指定多次
module.name_mapper.extension
。¥Note: You can specify
module.name_mapper.extension
multiple times for different extensions.
module.system
类型:node | haste
¥Type: node | haste
用于解析 import
和 require
的模块系统。Meta 使用 Haste 模式。
¥The module system to use to resolve import
and require
.
Haste mode is used by Meta.
默认为 node
。
¥The default is node
.
module.system.node.main_field
类型:string
¥Type: string
Flow 读取 package.json
文件中的 "name"
和 "main"
字段,以找出模块的名称以及应使用哪个文件来提供该模块。
¥Flow reads package.json
files for the "name"
and "main"
fields to figure
out the name of the module and which file should be used to provide that
module.
因此,如果 Flow 在 .flowconfig
中看到这一点:
¥So if Flow sees this in the .flowconfig
:
[options]
module.system.node.main_field=foo
module.system.node.main_field=bar
module.system.node.main_field=baz
然后它遇到了 package.json
¥and then it comes across a package.json
with
{
"name": "kittens",
"main": "main.js",
"bar": "bar.js",
"baz": "baz.js"
}
Flow 将使用 bar.js
来提供 "kittens"
模块。
¥Flow will use bar.js
to provide the "kittens"
module.
如果未指定此选项,Flow 将始终使用 "main"
字段。
¥If this option is unspecified, Flow will always use the "main"
field.
¥See this GitHub issue for the original motivation
module.system.node.resolve_dirname
类型:string
¥Type: string
默认情况下,Flow 将在名为 node_modules
的目录中查找节点模块。你可以使用此选项配置此行为。
¥By default, Flow will look in directories named node_modules
for node
modules. You can configure this behavior with this option.
例如,如果你这样做:
¥For example, if you do:
[options]
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=custom_node_modules
然后 Flow 将查找名为 node_modules
或 custom_node_modules
的目录。
¥Then Flow will look in directories named node_modules
or
custom_node_modules
.
注意:你可以多次指定
module.system.node.resolve_dirname
¥Note: you can specify
module.system.node.resolve_dirname
multiple times
module.use_strict
类型:boolean
¥Type: boolean
如果你使用将 "use strict";
添加到每个模块顶部的转译器,请将其设置为 true
。
¥Set this to true
if you use a transpiler that adds "use strict";
to the top
of every module.
默认值为 false
。
¥The default value is false
.
munge_underscores
类型:boolean
¥Type: boolean
将其设置为 true
以使 Flow 将以下划线前缀的类属性和方法视为私有。这应该与 jstransform
的 ES6 类变换 结合使用,后者在运行时强制执行相同的隐私。
¥Set this to true
to have Flow treat underscore-prefixed class properties and
methods as private. This should be used in conjunction with jstransform
's
ES6 class transform,
which enforces the same privacy at runtime.
默认值为 false
。
¥The default value is false
.
no_flowlib
类型:boolean
¥Type: boolean
Flow 具有内置库定义。将其设置为 true
将告诉 Flow 忽略内置库定义。
¥Flow has builtin library definitions. Setting this to true
will tell Flow to
ignore the builtin library definitions.
默认值为 false
。
¥The default value is false
.
react.runtime
≥0.123.0{#toc-react-runtime}
类型:automatic | classic
¥Type: automatic | classic
如果你在 @babel/plugin-transform-react-jsx
中使用 React 的自动运行时,请将其设置为 automatic
。否则,使用 classic
。参见 babel 文档 了解有关转换的详细信息。
¥Set this to automatic
if you are using React's automatic runtime in @babel/plugin-transform-react-jsx
.
Otherwise, use classic
. See the babel documentation
for details about the transform.
默认值为 classic
。
¥The default value is classic
.
server.max_workers
类型:integer
¥Type: integer
Flow 服务器可以启动的最大工作线程数。默认情况下,服务器将使用所有可用的核心。
¥The maximum number of workers the Flow server can start. By default, the server will use all available cores.
sharedmemory.hash_table_pow
类型:unsigned integer
¥Type: unsigned integer
共享内存的 3 个最大部分是依赖表、哈希表和堆。当堆增长和收缩时,两个表会被完全分配。此选项允许你更改哈希表的大小。
¥The 3 largest parts of the shared memory are a dependency table, a hash table, and a heap. While the heap grows and shrinks, the two tables are allocated in full. This option lets you change the size of the hash table.
将此选项设置为 X 意味着表将支持最多 2^X 个元素,即 16*2^X 字节。
¥Setting this option to X means the table will support up to 2^X elements, which is 16*2^X bytes.
默认情况下,该值设置为 19(表大小为 2^19,即 8 MB)
¥By default, this is set to 19 (Table size is 2^19, which is 8 megabytes)
sharedmemory.heap_size
类型:unsigned integer
¥Type: unsigned integer
此选项配置共享堆的最大可能大小。你很可能不需要配置此项,因为它并不会真正影响 RSS Flow 的使用量。但是,如果你正在处理大量代码库,你可能会在初始化后看到以下错误:“堆初始化大小太接近最大堆大小;GC 永远不会被触发!”在这种情况下,你可能需要增加堆的大小。
¥This option configures the maximum possible size for the shared heap. You should most likely not need to configure this, as it doesn't really affect how much RSS Flow uses. However, if you are working on a massive codebase you might see the following error after init: "Heap init size is too close to max heap size; GC will never get triggered!" In this case, you may need to increase the size of the heap.
默认情况下,该值设置为 26843545600(25 * 2^30 字节,即 25GiB)
¥By default, this is set to 26843545600 (25 * 2^30 bytes, which is 25GiB)
suppress_type
类型:string
¥Type: string
此选项允许你使用给定字符串为 any
起别名。这对于解释你使用 any
的原因很有用。例如,假设你有时想要使用 any
来抑制错误,有时想要标记 TODO。你的代码可能看起来像
¥This option lets you alias any
with a given string. This is useful for
explaining why you're using any
. For example, let's say you sometimes want
to sometimes use any
to suppress an error and sometimes to mark a TODO.
Your code might look like
const myString: any = 1 + 1;
const myBoolean: any = 1 + 1;
如果你将以下内容添加到你的配置中:
¥If you add the following to your configuration:
[options]
suppress_type=$FlowFixMe
suppress_type=$FlowTODO
你可以将代码更新为更具可读性:
¥You can update your code to the more readable:
const myString: $FlowFixMe = 1 + 1;
const myBoolean: $FlowTODO = 1 + 1;
注意:你可以多次指定
suppress_type
。¥Note: You can specify
suppress_type
multiple times.
traces
类型:integer
¥Type: integer
启用对所有错误输出的跟踪(显示有关通过系统的类型流的其他详细信息),直至指定的深度。这可能非常昂贵,因此默认情况下处于禁用状态。
¥Enables traces on all error output (showing additional details about the flow of types through the system), to the depth specified. This can be very expensive, so is disabled by default.
use_mixed_in_catch_variables
≥0.201{#toc-use-mixed-in-catch-variables}
类型:boolean
¥Type: boolean
将 catch
变量的默认类型从 any
更改为 mixed
。例如。
¥Changes the default type of catch
variables from any
to mixed
. E.g.
1try {2} catch (e) {3}
在上面的示例中,如果选项是 true
,则 catch
将被键入为 mixed
,因为它缺少显式类型注释。
¥in the above example, if the option is true
, catch
will be typed as mixed
as it lacks an explicit type annotation.
已弃用的选项
¥Deprecated options
最新版本的 Flow 中不再存在以下选项:
¥The following options no longer exist in the latest version of Flow:
esproposal.class_instance_fields
≤0.148{#toc-esproposal-class-instance-fields}
类型:enable | ignore | warn
¥Type: enable | ignore | warn
将其设置为 warn
以指示 Flow 应根据待定规范就使用实例 类字段 触发警告。
¥Set this to warn
to indicate that Flow should give a warning on use of
instance class fields
per the pending spec.
你还可以将其设置为 ignore
以指示 Flow 应简单地忽略该语法(即 Flow 不会使用此语法来指示类实例上存在属性)。
¥You may also set this to ignore
to indicate that Flow should simply ignore
the syntax (i.e. Flow will not use this syntax to indicate the presence of a
property on instances of the class).
此选项的默认值为 enable
,它允许使用此建议的语法。
¥The default value of this option is enable
, which allows use of this proposed
syntax.
esproposal.class_static_fields
≤0.148{#toc-esproposal-class-static-fields}
类型:enable | ignore | warn
¥Type: enable | ignore | warn
将其设置为 warn
以指示 Flow 应根据待定规范触发有关使用静态 类字段 的警告。
¥Set this to warn
to indicate that Flow should give a warning on use of static
class fields
per the pending spec.
你还可以将其设置为 ignore
以指示 Flow 应简单地忽略该语法(即 Flow 不会使用此语法来指示类上存在静态属性)。
¥You may also set this to ignore
to indicate that Flow should simply ignore
the syntax (i.e. Flow will not use this syntax to indicate the presence of a
static property on the class).
此选项的默认值为 enable
,它允许使用此建议的语法。
¥The default value of this option is enable
, which allows use of this proposed
syntax.
esproposal.decorators
≤0.148{#toc-esproposal-decorators}
类型:ignore | warn
¥Type: ignore | warn
将其设置为 ignore
以指示 Flow 应忽略装饰器。
¥Set this to ignore
to indicate that Flow should ignore decorators.
该选项的默认值为 warn
,它会在使用时触发警告,因为该提案仍处于早期阶段。
¥The default value of this option is warn
, which gives a warning on use since
this proposal is still very early-stage.
esproposal.export_star_as
≤0.148{#toc-esproposal-export-star-as}
类型:enable | ignore | warn
¥Type: enable | ignore | warn
将其设置为 enable
以指示 Flow 应支持 利拜伦的提议 中的 export * as
语法。
¥Set this to enable
to indicate that Flow should support the export * as
syntax from leebyron's proposal.
你还可以将其设置为 ignore
以指示 Flow 应简单地忽略语法。该选项的默认值为 warn
,它会在使用时触发警告,因为该提案仍处于早期阶段。
¥You may also set this to ignore
to indicate that Flow should simply ignore
the syntax. The default value of this option is warn
, which gives a warning
on use since this proposal is still very early-stage.
esproposal.optional_chaining
≤0.148{#toc-esproposal-optional-chaining}
类型:enable | ignore | warn
¥Type: enable | ignore | warn
将其设置为 enable
以指示 Flow 应支持根据待定规范使用 可选链接。
¥Set this to enable
to indicate that Flow should support the use of
optional chaining
per the pending spec.
你还可以将其设置为 ignore
以指示 Flow 应简单地忽略语法。
¥You may also set this to ignore
to indicate that Flow should simply ignore
the syntax.
该选项的默认值为 warn
,它会在使用时触发警告,因为该提案仍处于早期阶段。
¥The default value of this option is warn
, which gives a warning on
use since this proposal is still very early-stage.
esproposal.nullish_coalescing
≤0.148{#toc-esproposal-nullish-coalescing}
类型:enable | ignore | warn
¥Type: enable | ignore | warn
将其设置为 enable
以指示 Flow 应支持根据待定规范使用 无效合并。
¥Set this to enable
to indicate that Flow should support the use of
nullish coalescing
per the pending spec.
你还可以将其设置为 ignore
以指示 Flow 应简单地忽略语法。
¥You may also set this to ignore
to indicate that Flow should simply ignore
the syntax.
该选项的默认值为 warn
,它会在使用时触发警告,因为该提案仍处于早期阶段。
¥The default value of this option is warn
, which gives a warning on
use since this proposal is still very early-stage.
inference_mode
≥0.184.0≤0.202.0{#toc-inference-mode}
类型:classic | constrain-writes
¥Type: classic | constrain-writes
将其设置为 constrain-writes
将启用约束写入推断模式。
¥Setting this to constrain-writes
will enable the constrained-writes inference mode.
有关详细信息,请参阅 变量声明文档。
¥For more info, see the variable declaration docs.
默认值为 classic
¥The default value is classic
log.file
类型:string
¥Type: string
日志文件的路径(默认为 /tmp/flow/<escaped root path>.log
)。
¥The path to the log file (defaults to /tmp/flow/<escaped root path>.log
).
sharedmemory.dirs
类型:string
¥Type: string
这仅影响 Linux。
¥This affects Linux only.
Flow 的共享内存位于内存映射文件中。在更现代的 Linux 版本(3.17+)上,有一个系统调用 memfd_create
,它允许 Flow 仅在内存中匿名创建文件。然而,在较旧的内核中,Flow 需要在文件系统上创建一个文件。理想情况下,该文件位于内存支持的 tmpfs 上。此选项可让你决定在何处创建该文件。
¥Flow's shared memory lives in a memory mapped file. On more modern versions of
Linux (3.17+), there is a system call memfd_create
which allows Flow to create
the file anonymously and only in memory. However, in older kernels, Flow needs
to create a file on the file system. Ideally this file lives on a memory-backed
tmpfs. This option lets you decide where that file is created.
默认情况下,此选项设置为 /dev/shm
和 /tmp
¥By default this option is set to /dev/shm
and /tmp
注意:你可以多次指定
sharedmemory.dirs
。¥Note: You can specify
sharedmemory.dirs
multiple times.
sharedmemory.minimum_available
类型:unsigned integer
¥Type: unsigned integer
这仅影响 Linux。
¥This affects Linux only.
正如 sharedmemory.dirs
选项的描述中所解释的,Flow 需要在文件系统上为旧内核创建一个文件。sharedmemory.dirs
指定可以创建共享内存文件的位置列表。对于每个位置,Flow 将检查以确保文件系统有足够的空间用于共享内存文件。如果 Flow 可能会耗尽空间,它会跳过该位置并尝试下一个位置。此选项允许你配置文件系统上共享内存所需的最小空间量。
¥As explained in the sharedmemory.dirs
option's description, Flow needs to
create a file on a filesystem for older kernels. sharedmemory.dirs
specifies
a list of locations where the shared memory file can be created. For each
location, Flow will check to make sure the filesystem has enough space for the
shared memory file. If Flow will likely run out of space, it skips that location
and tries the next. This option lets you configure the minimum amount of space
needed on a filesystem for shared memory.
默认情况下,它是 536870912(2^29 字节,即半千兆字节)。
¥By default it is 536870912 (2^29 bytes, which is half a gigabyte).
strip_root
≤0.48{#toc-strip-root}
类型:boolean
¥Type: boolean
过时的。将其设置为 true
以便在使用 --json
、--from emacs
和 --from vim
时始终从错误消息中的文件路径中删除根目录。不要使用此选项。相反,传递命令行标志 --strip-root
。
¥Obsolete. Set this to true
to always strip the root directory from file paths
in error messages when using --json
, --from emacs
, and --from vim
.
Do not use this option. Instead, pass the command line flag --strip-root
.
默认情况下,这是 false
。
¥By default this is false
.
suppress_comment
≤0.126{#toc-suppress-comment}
类型:regex
¥Type: regex
定义一个神奇的注释,抑制下一行中的任何 Flow 错误。例如:
¥Defines a magical comment that suppresses any Flow errors on the following line. For example:
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
将匹配这样的注释:
¥will match a comment like this:
// $FlowFixMe: suppressing this error until we can refactor
var x : string = 123;
并抑制错误。如果下一行没有错误(不需要抑制),则会显示 "未使用的抑制" 警告。
¥and suppress the error. If there is no error on the next line (the suppression is unnecessary), an "Unused suppression" warning will be shown instead.
如果你的配置中没有指定抑制注释,Flow 将应用一个默认值:// $FlowFixMe
。
¥If no suppression comments are specified in your config, Flow will apply one
default: // $FlowFixMe
.
注意:你可以多次指定
suppress_comment
。如果你确实定义了任何suppress_comment
,则内置的$FlowFixMe
抑制将被删除,以支持你指定的正则表达式。如果你希望将$FlowFixMe
与一些其他自定义抑制注释一起使用,则必须在自定义抑制列表中手动指定\\(.\\|\n\\)*\\$FlowFixMe
。¥Note: You can specify
suppress_comment
multiple times. If you do define anysuppress_comment
s, the built-in$FlowFixMe
suppression will be erased in favor of the regexps you specify. If you wish to use$FlowFixMe
with some additional custom suppression comments, you must manually specify\\(.\\|\n\\)*\\$FlowFixMe
in your custom list of suppressions.
注意:在 v0.127.0 版本中,删除了指定抑制注释语法的选项。
$FlowFixMe
、$FlowIssue
、$FlowExpectedError
、$FlowIgnore
成为唯一的标准压制。¥Note: In version v0.127.0, the option to specify the suppression comment syntax was removed.
$FlowFixMe
,$FlowIssue
,$FlowExpectedError
, and$FlowIgnore
became the only standard suppressions.
temp_dir
类型:string
¥Type: string
告诉 Flow 将哪个目录用作临时目录。可以用命令行标志 --temp-dir
覆盖。
¥Tell Flow which directory to use as a temp directory. Can be overridden with the
command line flag --temp-dir
.
默认值为 /tmp/flow
。
¥The default value is /tmp/flow
.
types_first
≥0.125.0≤0.142{#toc-types-first}
类型:boolean
¥Type: boolean
有关类型优先模式的更多信息,请参阅 类型优先文档。
¥For more on types-first mode, see the types-first docs.
Flow 构建中间工件来表示检查模块的签名。如果此选项设置为 false
,则这些工件是使用推断的类型信息构建的。如果此选项设置为 true
,则它们是在模块边界使用类型注释构建的。
¥Flow builds intermediate artifacts to represent signatures of modules as they are
checked. If this option is set to false
, then these artifacts are built using
inferred type information. If this option is set to true
, then they are built
using type annotations at module boundaries.
types_first
的默认值为 true
(从版本 0.134 开始)。
¥The default value for types_first
is true
(as of version 0.134).
well_formed_exports
≥0.125.0≤0.142{#toc-well-formed-exports}
类型:boolean
¥Type: boolean
对文件导出实现以下限制:
¥Enforce the following restrictions on file exports:
操作
module.exports
和exports
别名的语句只能显示为顶层语句。¥Statements manipulating
module.exports
and theexports
alias may only appear as top-level statements.从文件导出中可见的源部分需要进行注释,除非可以轻松推断出它们的类型(例如导出的表达式是数字字面量)。这是类型优先模式正常运行的要求。未能正确注释导出会引发
signature-verification-failure
。¥Parts of the source that are visible from a file's exports need to be annotated unless their type can be trivially inferred (e.g. the exported expression is a numeric literal). This is a requirement for types-first mode to function properly. Failure to properly annotate exports raise
signature-verification-failure
s.
该选项默认设置为 true
,因为它是由 types_first
隐含的,但是当将项目从经典模式升级到类型优先模式时,该选项本身很有用。
¥This option is set to true
by default, since it is implied by types_first
,
but the option is useful on its own when upgrading a project from classic mode to
types-first mode.
well_formed_exports.includes
≥0.128.0≤0.142{#toc-well-formed-exports-includes}
类型:string
¥Type: string
将 well_formed_exports
要求的范围限制到该项目的特定目录。例如
¥Limit the scope of the well_formed_exports
requirement to a specific directory
of this project. For example
well_formed_exports=true
well_formed_exports.includes=<PROJECT_ROOT>/dirA
well_formed_exports.includes=<PROJECT_ROOT>/dirB
只会报告 dirA
和 dirB
下文件中与导出相关的错误。该选项要求将 well_formed_exports
设置为 true
。
¥will only report export related errors in files under dirA
and dirB
. This option
requires well_formed_exports
to be set to true
.
此选项的目的是帮助为 Flow 类型优先模式准备代码库。
¥The purpose of this option is to help prepare a codebase for Flow types-first mode.
在版本 v0.125.0 和 v0.127.0 之间,此选项被命名为 well_formed_exports.whitelist
。
¥Between versions v0.125.0 and v0.127.0, this option was named well_formed_exports.whitelist
.