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

Add ConditionalKeys, ConditionalPick and ConditionalExcept types #76

Merged
merged 10 commits into from Feb 14, 2020

Conversation

ifiokjr
Copy link
Contributor

@ifiokjr ifiokjr commented Feb 4, 2020

Description

Add types to conditionally pick and exclude properties from any shape based on the provided Condition.

This type comes in handy quite a lot in my library code bases where transforming types or picking properties based on conditions helps dynamically drive automatic inference.

Any suggestions for better names is welcome. Since this code base provides the Except type I've used the name ConditionalExcept. However, it might be more understandable to use ConditionalOmit.

Copy link
Contributor

@resynth1943 resynth1943 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some minor errors, but overall I love this proposal, and I thank you for your contribution

source/conditionals.d.ts Outdated Show resolved Hide resolved
source/conditionals.d.ts Outdated Show resolved Hide resolved
source/conditionals.d.ts Outdated Show resolved Hide resolved
source/conditionals.d.ts Outdated Show resolved Hide resolved
source/conditionals.d.ts Outdated Show resolved Hide resolved
source/conditionals.d.ts Outdated Show resolved Hide resolved
source/conditionals.d.ts Outdated Show resolved Hide resolved
source/conditionals.d.ts Outdated Show resolved Hide resolved
source/conditionals.d.ts Outdated Show resolved Hide resolved
test-d/conditionals.ts Outdated Show resolved Hide resolved
@resynth1943
Copy link
Contributor

Any suggestions for better names is welcome. Since this code base provides the Except type I've used the name ConditionalExcept. However, it might be more understandable to use ConditionalOmit.

Nah. ConditionalExcept should be fine here, as it relies on the Except type, not the Omit type.

@ifiokjr
Copy link
Contributor Author

ifiokjr commented Feb 6, 2020

I'll address the requested changes once I have a few moments.

@ifiokjr ifiokjr force-pushed the conditionals branch 2 times, most recently from dadae29 to 7f437b2 Compare February 9, 2020 07:31
@ifiokjr
Copy link
Contributor Author

ifiokjr commented Feb 9, 2020

I've addressed the requested changes with some minor deviations as explained above.

@ifiokjr ifiokjr closed this Feb 9, 2020
@ifiokjr ifiokjr reopened this Feb 9, 2020
@resynth1943
Copy link
Contributor

/cc @sindresorhus LGTM.

@resynth1943
Copy link
Contributor

Merged in 1... 2... 3... 😛

@sindresorhus sindresorhus changed the title Add ConditionalKeys, ConditionalPick and ConditionalExcepttypes Add ConditionalKeys, ConditionalPick and ConditionalExcept types Feb 14, 2020
@sindresorhus sindresorhus merged commit 8a908a3 into sindresorhus:master Feb 14, 2020
@sindresorhus
Copy link
Owner

Thanks, @ifiokjr 👌

@ifiokjr ifiokjr deleted the conditionals branch February 15, 2020 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants