我想知道是否有可能引入一些条件逻辑来根据输入类型产生$Call
的返回类型。
我能想到的一个简单示例是获取Flow类型的字符串。
// @flow
type Options = {|
foo: string,
bar: number
|}
type ExtractReturnType = <V: number>(V) => 'number' & <V: string>(V) => 'string'
type $Extract = $ObjMap<Options, ExtractReturnType>
const f: $Extract = {
foo: ('string': 'string'),
bar: ('number': 'number')
}