Flow: ObjMap example broken since 0.57.0

Created on 19 Nov 2017  路  7Comments  路  Source: facebook/flow

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

0.56.0:

screen shot 2017-11-19 at 15 45 06

0.57.0 and higher:

screen shot 2017-11-19 at 15 45 19

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

destructors

Most helpful comment

Any updates on this? Seems pretty average to add a regression 8 versions ago now, and now address it.

All 7 comments

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?

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

funtaps picture funtaps  路  3Comments

john-gold picture john-gold  路  3Comments

marcelbeumer picture marcelbeumer  路  3Comments

philikon picture philikon  路  3Comments

jamiebuilds picture jamiebuilds  路  3Comments