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

feat(resolve): resolve Object.keys() in PropType.oneOf() #211

Merged
merged 2 commits into from
Sep 5, 2017
Merged

feat(resolve): resolve Object.keys() in PropType.oneOf() #211

merged 2 commits into from
Sep 5, 2017

Conversation

danez
Copy link
Collaborator

@danez danez commented Aug 24, 2017

Creates a new util to extract keys from Object.keys() and ObjectExpressions when used inside of oneOf()
It also follows spreads and tries to resolve them. Currently it bails out if either a Property is computed and the computed key is not a Literal or if a spread cannot be resolved.

Getters will be handled the same as normal properties, but setters will be ignored. Not sure if this makes 100% sense, but this can be easily changed.

This fixes #153.

As a follow up the same can be done easily for Object.values.

!! When this gets merged to v3, SpreadProperty needs to be replaced with SpreadElement !!

Creates a new util to extract keys from ObjectExpressions.
This does not ignore setters, but deduplicate the resolved entries and
makes them unique.
@danez danez merged commit 55bbefe into reactjs:master Sep 5, 2017
@danez danez deleted the object-keys branch September 5, 2017 11:59
@romanlex
Copy link

Hello, anybody can merge this pr to v3-dev branch?

@stepancar
Copy link

@danez

@stonebk
Copy link

stonebk commented Oct 16, 2018

It would be great if this could be done for Object.values() as well as @danez mentioned.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support Object.keys within oneOf
4 participants