Update: propEq to allow wider-typing for value in comparison#74
Merged
Harris-Miller merged 9 commits intodevelopfrom Feb 13, 2024
Merged
Update: propEq to allow wider-typing for value in comparison#74Harris-Miller merged 9 commits intodevelopfrom
Harris-Miller merged 9 commits intodevelopfrom
Conversation
Nemo108
approved these changes
Oct 16, 2023
Contributor
There was a problem hiding this comment.
This is a really great solution to the problem. It looks like it can fix almost all of the problems I face during development.
I agree about clearing up allPass and anyPass tests since they are unit tests and should not depend on any other function. However, it may be a better idea to make integrational tests somewhere, to ensure that functions can work okay together since sometimes typings updates can break the co-usage of the functions.
…args or return types
dcbe597 to
aab5114
Compare
This was referenced Feb 22, 2024
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.
See this playground for full tests: https://tsplay.dev/mMlMdN
propEqneeds a lot of updating. This MR is one of 3 towards that effort.This first effort is just to update the typings to allow for a more correct range of typing when passing a
valwithout yet knowing the type ofobjtl;dr is that when we know the type of
valbut not the type ofobj, we're allowing for a wider type range for better support. These additions fix the following issues that the current typings don't support:stringbut the prob type isstring | number| null(eg nullable)The downside to these changes is that we lose errors when the types at
obj.propdon't at all overlap with the type ofval, but it will returnneverin those cases, which is better than nothingSince the we know the type of
valandobjat the same time with the full function signaturepropEq(val, name, obj), that signature can remain strict, since the above cases are not an issue with the full signatureTODO: update tests for
allPassandanyPassso they don't rely onpropEq. I don't want have to continuously update those as we updatepropEq. Those tests should stand on their own