-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: reshape finally #148
Conversation
after reading readme again, i think I've understood reshape incorrectly. Will change it |
Codecov Report
@@ Coverage Diff @@
## main #148 +/- ##
=======================================
Coverage 99.28% 99.28%
=======================================
Files 55 55
Lines 3198 3205 +7
Branches 795 796 +1
=======================================
+ Hits 3175 3182 +7
Misses 13 13
Partials 10 10
Continue to review full report at Codecov.
|
tests/validators/base.test.ts
Outdated
: // FIXME: if I don't add this number generic, then `reshape` isn't able to infer the type | ||
// Lmk should I keep it like this or r there any fix possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this a Results 2.0 issue 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shapeshift don't uses @sapphire/result
. The issue is Result.ok(number)
becomes Result<number, Error>
and Result.err(Error)
becomes Result<unknown, Error>
so the return type becomes Result<number, Error> | Result<unknown, Error>
but reshape
expects only one type that's why it errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh lord. Maybe that's why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a fix. But now Result.err(new Error('message'))
is showing Result<string>
idk why. Can u check again pls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we used @sapphire/result
, tho? Shapeshift uses a class-based stripped-down version of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth adding the full package when shapeshift only uses Ok
and err
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was for shapeshift to be dependency-less, we've already had to accept some dependencies for the sake of browser compatibility / other validation library parity in fast-deep-equal
and lodash.uniqwith
but I would still prefer to keep it at a very low minimum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I think it's fine this way. I think the way the types are set up now will be pretty seamless for the end-users and ultimately that's what matters most.
No description provided.