flow check --max-warnings 0
在整个unittests文件夹(或整个代码库)上,并断言该命令具有0退出状态(没有错误或警告)。您不需要单独在每个单元测试文件上运行这些命令。
documentation for
suppress_comment
表示,如果您编写抑制注释(如
// $FlowExpectError
在实际上不会触发流错误的行上方。
取消\u注释
$FlowExpectError
作为一个注释,您的单元测试是这样的:
// this type definition could be imported from another file
type User = {|
name: string
|};
// Check that Flow doesnât raise an error for correct usages
const user = {name: "Bob"};
// Check that Flow does raise an error for incorrect usages
// $FlowExpectError
const user = {name: "Bob", age: 40};
如果你跑了
流量检查--最大警告0
在包含此文件的文件夹上,命令成功退出,然后对
User
类型已通过。