I don't understand why this is not working. I expect $ObjMap to require that the object return the value, or a function that returns that value. See the comment in the code. Anyone know how to make this work?
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,
};
from ObjMap return value or function
No comments:
Post a Comment