I'm using objects as maps in the example below. It appears the type of Object.values is an array of mixed as opposed to an array of the Point type I defined.
type Point = {
x: number,
y: number,
};
type PointMap = { [key:string]: Point }
const foo: PointMap = { "1": { x: 5, y: 6}, "2": { x: 7, y: 8} };
Object.values(foo).map(p => {
return p.x;
})
It appears if I do use Object.keys instead, flow can correctly infer the type of foo[key]
Object.keys(foo).map(key => {
return foo[key].x;
})
This seems like a bug in flow, as we use Object as a map here and the type checker has enough info to correctly infer the type of Object.values(). Yes?
I'm using objects as maps in the example below. It appears the type of Object.values is an array of mixed as opposed to an array of the Point type I defined.
It appears if I do use Object.keys instead, flow can correctly infer the type of foo[key]
This seems like a bug in flow, as we use Object as a map here and the type checker has enough info to correctly infer the type of Object.values(). Yes?