facebook/flow

Record types should refine Object.values

flex-tjon opened this issue · 2 comments

Hi, thanks for reporting, and I'm very pleased to see someone already making use of Flow's mapped types in the wild!

This is currently working as intended, though I do understand your frustration. The two object types you show in your example are different despite looking the same. PurchaseTypes is an indexed object type while PurchaseTypesRecord gets evaluated to {PERCENT: string, DOLLAR: string, CO2: string}. We currently have a special case that supports Object.values in a special way for indexed objects, but that does not apply to objects without indexers.

Record is special in that it gets rid of the typical reason we give for returning mixed, which is that inferring arbitrary unions of object values would be very bad for performance, but this would take some non-trivial work to implement.

didn't mean to close, leaving open