Add ExtendsOr, ExtendsAnd, and ExtendsThenElse types#247
Closed
tmillr wants to merge 1 commit intosindresorhus:mainfrom
Closed
Add ExtendsOr, ExtendsAnd, and ExtendsThenElse types#247tmillr wants to merge 1 commit intosindresorhus:mainfrom
ExtendsOr, ExtendsAnd, and ExtendsThenElse types#247tmillr wants to merge 1 commit intosindresorhus:mainfrom
Conversation
Owner
|
@Tyler1205 If you have time, it would be great if you could help review some of the other open pull requests. 🙏 |
Owner
|
I'm a little bit conflicted about this. It tries to simplify code with utilities, but we also have to learn the utilities. When I person reading the code sees |
Contributor
|
I am not sure either. I have also needed these helpers in the past in a few situations, but I just defined them myself so anyone reading my code will be able to understand without having to look it up. |
Owner
|
I have decided to decline this as the benefits are not worth the learnability overhead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A few basic utility types that act as
||and&&shorthands.The third type is simply an if/then/else conditional which simply mirrors the behavior of typescript's
extendsternary conditional expression (yeah I know not very useful but it allows for alternative syntax/style).These utilities could also have other names such as:
ExtendsOr->OrExtendsAnd->AndExtendsThenElse->CondorConditionorConditionalorTernaryetc....but I thought these names were ok.
These are all simple utilities, so how they work should be rather easy to figure out, although I did try to provide some examples (including an example that reflects a problem that originally inspired this idea having to do with Parameters<> erroring if it is not sure that it is receiving a Function).