Javascript FlowJS:从联合中提取类型
在flowjs中是否可以从联合类型中提取类型 我尝试了下面的例子,但没有成功Javascript FlowJS:从联合中提取类型,javascript,flowtype,Javascript,Flowtype,在flowjs中是否可以从联合类型中提取类型 我尝试了下面的例子,但没有成功 type ExtractType = <T>(T | () => T) => T; type Config = string | () => string; type S = $Call<ExtractType, Config>; const str1: S = 'str'; // Error: requires function const str2: S = () =&g
type ExtractType = <T>(T | () => T) => T;
type Config = string | () => string;
type S = $Call<ExtractType, Config>;
const str1: S = 'str'; // Error: requires function
const str2: S = () => 'str'; // Error: requires string
type-ExtractType=(T |()=>T)=>T;
类型Config=string |()=>string;
类型S=$Call;
常量str1:S='str';//错误:需要函数
常量str2:S=()=>“str”;//错误:需要字符串