flow/flow-bin

Contravariant inputs not working with object maps

Closed this issue · 1 comments

The idea of contravariant inputs as described in the flow docs appears to not be working when used in an object map.

This Flow try will give the best idea of what's going on.

When we have a map of generic objects (myStudents) the function which expects less specific objects (acceptsNamedMap) can receive the generic object just fine. When we annotate the object with a flow type, flow says that we can't pass the annotated map into the function anymore. As seen in the flow try, this works just fine when the object is not in a map, it only breaks when the object is in an 'object map' and annotated.

mroch commented

Please report this on https://github.com/facebook/flow, as it has to do with Flow itself and not flow-bin, which just packages the binaries for npm. Thanks!