检查以下内容的流程范围:
// @flow
import type { Map } from 'immutable';
import { fromJS } from 'immutable';
const formOptions: {
foo: Map<string, *>,
} = {
foo: fromJS({
some: 'value',
}),
};
它将fromJS
部分报告为未覆盖:
$ ./node_modules/.bin/flow coverage --json --pretty foo.js
{
"expressions":{
"covered_count":5,
"uncovered_count":1,
"uncovered_locs":[
{
"source":"/Users/jacob/Code/nova/manage-web/app/containers/ResendVerification/foo.js",
"type":"SourceFile",
"start":{"line":8,"column":8,"offset":141},
"end":{"line":10,"column":4,"offset":173}
}
]
}
}
如何对其进行注释以确保完全覆盖?
答案 0 :(得分:1)
这是因为fromJS
会返回any
。
如果构建了“正确键入的”地图,则覆盖:
// @flow
// import type { Map } from 'immutable';
import { Map } from 'immutable';
const formOptions: {
foo: Map<string, *>,
} = {
foo: Map({
some: 'value',
}),
};