Flow: Does not handle generic functions with specified params + return type properly

Created on 1 Oct 2019  路  2Comments  路  Source: facebook/flow

Flow doesn't seem to support specifying generics where a function is the parameter and the generics are parameters and return type. This is a lot easier explained in my example below

Flow version: Latest

Expected & Actual behavior

https://flow.org/try/#0GYVwdgxgLglg9mABBANggpgcXWdAnGCAHgAUBDPMgWwGcAaRAJXShDzABUBPAB3QD4AFKEgAuRIJ4VqNceUq0AlIgC8-Jizade6ZQG8AUIkR5N7CVIWzE8mcrWJDx46dbmRESdKUBuI4gBfPyD-Z2cDKB1EAFkuW1pVRwMASCh0GihxMBAqACN8MMLEAwDQwoio2OY3bT5Ew1T0zMRsvPwfIrCSsq6PWAREKi4OJoAxcGh4MC8rcVj4mkU5rmqtbjqG1y0ksMaM8QBGMtLSgwgEDOQ0XAATWJGM8ch+pBUrjGxcAk8hh6gnyYIRR+M7XdB3YZjCYvQR6NL7RAAJgCygA9KjEFAABYwGiIGhYuAgFA3RAAdzgeAA1qCMBC-gCYXCcTQAMqE4k3UZkGAocTI4GIdGYln4jkkxDAHkoAwGIA

bug needs triage

All 2 comments

@Michael-M-Judd, you are right the type inference does not work as expected but typing the return of the cloneGeneric function does what you expect - see here for flow try

Flow does not infer polymorphic values, which is why you get an error without the annotation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamiebuilds picture jamiebuilds  路  3Comments

cubika picture cubika  路  3Comments

bennoleslie picture bennoleslie  路  3Comments

mjj2000 picture mjj2000  路  3Comments

tp picture tp  路  3Comments