support retrieving all property values via ramda#4
Open
alexkolson wants to merge 5 commits intoalexbepple:masterfrom
Open
support retrieving all property values via ramda#4alexkolson wants to merge 5 commits intoalexbepple:masterfrom
alexkolson wants to merge 5 commits intoalexbepple:masterfrom
Conversation
so this wasnt so much a problem with getting all properties but rather with the way getting all properties with ramda works and ramda internals ramda internall checks to see if an argument is its internal placeholder thingy soemtimes and to do that it looks to see if there is a propery on the argument with the key "@@functional/placeholder". This of course invokes the get trap and the unkown property error is thrown. Quick fix is just to check if the property being asked for is the placeholder property and if so just short circuit. It feels a bit strange to be doing ramda specific checks but at the same time given the functional nature of kiss and type i dont think its too strange.
alexbepple
reviewed
Oct 28, 2019
src/create-type.test.js
Outdated
| it('all props can be retrieved with ramda', () => { | ||
| const doesNotThrow = __.not( | ||
| __.throws( | ||
| __.typedError(TypeError, __.containsString('Unknown')) |
Owner
There was a problem hiding this comment.
Similarly to PR #2, what do you think about relaxing the assertion? How about just __.not(__.throws())?
alexbepple
reviewed
Oct 28, 2019
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.
This wasn't so much a problem with getting all properties but rather with the way getting all properties with ramda works and ramda internals. Ramda internaly checks to see if an argument is its internal placeholder thingy sometimes and to do that it looks to see if there is a property on the argument with the key
@@functional/placeholder. This of course invokes the get trap and the unknown property error is thrown.Quick fix is just to check if the property being asked for is the placeholder property and if so just short circuit. It feels a bit strange to be doing ramda specific checks but at the same time given the
functional nature of kiss and type i don't think its too terrible :)
I think maybe a refactored long-term solution would be a way to tell a type what properties are allowed to be undefined, or even better, for what properties traps should not be invoked.