Skip to content
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

Merged
merged 4 commits into from
Jul 9, 2022
Merged

feat: reshape finally #148

merged 4 commits into from
Jul 9, 2022

Conversation

imranbarbhuiya
Copy link
Contributor

No description provided.

@imranbarbhuiya
Copy link
Contributor Author

imranbarbhuiya commented Jul 6, 2022

after reading readme again, i think I've understood reshape incorrectly. Will change it after dinner tomorrow

@favna favna marked this pull request as draft July 6, 2022 21:32
@codecov-commenter
Copy link

codecov-commenter commented Jul 6, 2022

Codecov Report

Merging #148 (138d8e9) into main (ad7af34) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           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           
Impacted Files Coverage Δ
src/lib/util-types.ts 100.00% <ø> (ø)
src/validators/BaseValidator.ts 99.14% <100.00%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad7af34...138d8e9. Read the comment docs.

@imranbarbhuiya imranbarbhuiya marked this pull request as ready for review July 6, 2022 23:50
Comment on lines 148 to 149
: // 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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 👀

Copy link
Contributor Author

@imranbarbhuiya imranbarbhuiya Jul 7, 2022

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.

Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

@kyranet kyranet Jul 7, 2022

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

favna
favna previously approved these changes Jul 8, 2022
Copy link
Member

@favna favna left a 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.

@favna favna merged commit d3751f6 into sapphiredev:main Jul 9, 2022
@imranbarbhuiya imranbarbhuiya deleted the feat/reshape-finally branch July 9, 2022 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants