You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When annotating a dictionary as a Record, calling Object.values on that dictionary should return whatever the record type is: this is the way Object.values handles dictionaries that are created using indexed object syntax
Actual behavior
Calling Object.values returns an array of mixed elements instead.
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.
Flow version: 0.210.0
Expected behavior
When annotating a dictionary as a
Record
, callingObject.values
on that dictionary should return whatever the record type is: this is the wayObject.values
handles dictionaries that are created using indexed object syntaxActual behavior
Calling
Object.values
returns an array ofmixed
elements instead.The text was updated successfully, but these errors were encountered: