-
Notifications
You must be signed in to change notification settings - Fork 129
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
isDeepEqual and negation in guard can break type #634
Comments
Hmm, Interestingly enough though, the above works with the data-last case, if it helps you as a quick workaround. Not sure why though. function effect(oldValue: Foo, newValue: Foo) {
if (!R.isDeepEqual(oldValue)(newValue)) {
reset(oldValue.bar);
// ^? is now `Foo`
}
} |
Two variables can be of the same type and not be strictly equivalent. |
Thanks, but it didn't work for me, IRL I use both values in code :) |
Thanks for reporting this; that's a good observation I missed when converting it to a narrowing type. I'll see if I can come up with a fix that would still support some narrowing where it works with typescript. |
I think the point was that if two objects are deeply equal, they necessarily are of the same type (since we don't have named types in TS). Say Rather than loosening the return type to |
Fixes: #634 Narrowing the result of isDeepEqual is redundant when the type isn't effectively narrowed because it breaks the rejected/negated path which would be `never`. This means that the common use case where both objects are of the same type and narrowing was meaningless, will now act as a regular boolean check.
🎉 This issue has been resolved in version 1.58.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I get
never
for firstisDeepEqual
argument and I can't use it:demo: https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAKjgQwM5wEpwGZQiOAcigFMQSATZQgbgCg6YBPMEuAMQgjgF44BvOnGFwARsigAuOKhhRgAOwDm9AL4NsAVwUBjGMAgK4pVCRgAKcVJlzFSgJQD1dLbv2G4JbNhJ7zEABsKADVkAM0SaU4IABo4BRIAd1DwyI4uR0EROGBsOHMAQgwAOmBUABESEjAAUQBHTTD-IJSIuITksIj7TKFskRMzZpCukmKre3ps9VUgA
The text was updated successfully, but these errors were encountered: