【发布时间】:2021-02-07 02:14:37
【问题描述】:
我不明白为什么这不起作用。我希望 $ObjMap 要求对象返回该值,或返回该值的函数。请参阅代码中的注释。有谁知道如何进行这项工作?
type TObj = {|
a: number,
b: string,
c: boolean,
|};
type Extract = <V>(V) => (() => V) | V
type TType = $ObjMap<TObj, Extract>
function a (): string {
return 'a';
}
// Expect a to have an error as it is a function that returns a string.
// $ObjMap states that it must be either a number, or a function that returns
// a number.
const t: TType = {
a,
b: 'v',
c: true,
};
【问题讨论】:
标签: javascript flowtype