Looks like the changes to $ObjMap broke something in the example: https://flow.org/en/docs/types/utilities/#toc-objmap
0.56.0:

0.57.0 and higher:

I'd love to know if this is a bug or a changing api, as the $ObjMap example is almost identical to something I'm trying to type up at the moment.
Thanks!
https://flow.org/try/#0PTAEAEDMBsHsHcBQiSmgUwC4HIDOp4AnAS03VAENRMBPAB3QwDdHRIBXAOwGNNjZO1ABYVM1CgGt0+KgAMAFAEpQAXgB8oAGqzKnACahCWdoU4zQs7aHml8RzCcG0GixM-IBRAB6ZCFXgBKxqYAKvTkKqAAPJpq8kqqGprK6lrIHDx8AoZcUQCCADSgAPIAXKAA3gDaUjTluL7EnADmALrlCal5AL5xsOXFiuUAJMUARgBWALIUdFHFRd6+-phBDqHhGhWIoIbBguMT6LwAdLW48rCKJ0Z67Nzo8f7cRRIpGofHmCcUuLjEzU48meRQqoBq7VAsAhCW6ilBcIA3IhushuAIGlDVJUdpQOu9qIR2OgCrixvjEqBsJBYLBsCjkYh5ESgVcfuUxrSMBROIpEaBUMUJEyWZdruTQA0SC0+btBcKgA
This just seems like a very bad example that is not supposed to work. This works fine:
type ExtractReturnType = <V>(() => V) => V
declare function run<A, O>(o: O): $ObjMap<O, ExtractReturnType>;
const o = {
a: () => true,
b: () => 'foo'
};
(run(o).a: boolean); // Ok
(run(o).b: string); // Ok
@vkurchatkin that fixes the return type, but the args are no longer enforced:
type ExtractReturnType = <V>(() => V) => V
declare function run<A, O>(o: O): $ObjMap<O, ExtractReturnType>;
const o = {
a: () => true,
b: () => 'foo'
};
(run(o).a: boolean); // Ok
(run(o).b: string); // Ok
run({ cat: "dog" }) // Ok, but I would like an error...
That is a regression, unfortunately
Thats a shame. Anything I can do to help?
Probably related: https://github.com/facebook/flow/issues/5428
Any updates on this? Seems pretty average to add a regression 8 versions ago now, and now address it.
It errors if you access value
https://flow.org/try/#0C4TwDgpgBAogHsATgQwMbAEoWAV0QOwBVxoBeKAHgDUA+ACgDMAuKOgSilJqio654BQAgCYRUAG2SJoDHPnQBLAPb4oiORQCCAGigB5ekpZ62LACR6ARgCsAssjAU9u+EjSZseIiRoBuAVCBUAKoKgDOwFBKnFAA3gFQyCzsnNxIOBDaCZbJfNwA5AxKSvkCAL7+AnTq+HRKbAB0SVCWxeIQyPhsvlAA9L36ANZVNXWNOVARiAr4AObdgf1DIeGRAG7I4jGjsVCoyMAsAETCSrNHUGUcS3qDupY4kQCSUADuSjjiwlDiCoPQnSgEEQiCUiAaEKEG3EDX2wCAA
Most helpful comment
Any updates on this? Seems pretty average to add a regression 8 versions ago now, and now address it.