Closed macksal closed 2 weeks ago
Latest commit: 7767eabe4dab1f40c037f7b617ae0117c81dd179
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Would really appreciate this being implemented!
Would really appreciate this being implemented!
Please help by providing a code review and hopefully we can get attention from the maintainers @supermacro @m-shaka. I'm using this in production and have considered forking, but this is already a fairly niche library and I hope we could maintain some kind of central community.
Thank you @supermacro @m-shaka for merging.
Would you consider reviewing another PR of mine, #588? It is adding a commonly requested feature including test coverage. I will appreciate any comment on whether this feature could be accepted.
When implementing a function returning a result, it's often that I need to construct an
Ok<void>
object. However, it's not so ergonomic to do this.ok
must be passed an argument, even if you explicitly specify thevoid
type. This leads to passing a "dummy" value:Meanwhile, in Promise-land, it's perfectly acceptable to call
Promise.resolve()
with no arguments, which returns aPromise<void>
.Interestingly, TS allows a parameter to be omitted if it has type
void
. However, this does not work if the type is generic and has been expanded tovoid
or a union containingvoid
. See https://github.com/Microsoft/TypeScript/issues/29131This PR adds additional overloads for
ok
,err
,okAsync
anderrAsync
that separate out the case where the argument type isvoid
. This allows the following to work as expected: