Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record types should refine Object.values #9042

Open
flex-tjon opened this issue Jun 27, 2023 · 2 comments
Open

Record types should refine Object.values #9042

flex-tjon opened this issue Jun 27, 2023 · 2 comments
Assignees

Comments

@jbrown215
Copy link
Contributor

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.

@jbrown215 jbrown215 reopened this Jun 27, 2023
@jbrown215
Copy link
Contributor

didn't mean to close, leaving open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants