Releases: supermacro/neverthrow
Fix empty dist folder
New `ResultAsunc.fromThrowable`
Addresses #488 & implements the .fromThrowable
method on ResultAsync
.
Thanks to @ehaynes99 for implementing this π
π Reminder; I'm looking for a maintainer to help out:
Emulation of Rusts `?` Result operator (implicit return for errors)
neverthrow
now can support implicit return whenever there is an Err
instance inside of a generator.
Context: #448
Thank you to @tsuburin for the contribution π
Additionally, the previous functionality around increasing the tuple size supported by neverthrow
is now live and out of beta. Context: https://github.com/supermacro/neverthrow/releases/tag/v6.0.1-0
Release Candidate: Allow for type inference of tuples containing 49 or less elements
I am a simple man - I like my tuples like my coffee; small (but strong). But some of you are out here trying to wreak havoc on the world with very large tuples. Now you get type inference on these too π
This is a fix for #441
The fix allows for type inference on very large tuples (limit of 49).
Given the sensitive nature of the changes made at the type level, I've opted to release this incrementally and as an opt-in functionality for now.
To get this change, you'll need to update your neverthrow
installation to use the @beta
tag.
> npm install neverthrow@beta
I'll wait a bit before moving this over to default
on npm.
Resolve accidental breaking change with type inference on array types
The combine*
family of functions (both sync and async) broke any codebase that called these functions on arrays of varying lengths when the previous release was shipped:
https://github.com/supermacro/neverthrow/releases/tag/v5.1.0
The following fix was implemented to address this issue and ensure that arrays (not just tuples) work with the combine*
family of functions.
Why is this shipped as a MAJOR version change?
Because we are now explicitly depending on TypeScript's variadic tuple types feature, which came out in v4 of TypeScript:
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html#variadic-tuple-types
Acknowledgements
Thank you to @ghost91- for implementing the fix π
Type inference improvements for all of the "combine" functions!
Thanks to @incetarik for fixing a long-lasting developer inconvenience! #226
Now, all of the "combine" functions can now infer types correctly and treat the list argument as a tuple rather than an unbounded list!
i.e. Rather than having to do:
Result.combine([ ok(123), err('whopps!') ] as const)
You can just omit the as const
now:
Result.combine([ ok(123), err('whopps!') ])
And neverthrow
can figure out the type of the above tuple on its own!
Return `never` rather than `unknown` for error type of `ResultAsync.fromSafePromise`
Thank you to @ccjmne @lmcsu and @msheakoski for this improvement π
This release ships #425 - which ensures that the E
type for ResultAsync.fromSafePromise
is never
by default - which makes a lot more sense / is more a "accurate" depiction of runtime behaviour.
Separate `combine` and `combineWithAllErrors` into sync & async APIs
Thank you to @tam-carre for implementing this fix!
Unfortunately there is no way to distinguish at runtime if an empty list is a list of ResultAsync
s or a list of Result
s.
Hence #381 ... which could cause runtime exceptions!
So we've had to make the unfortunate decision of splitting combine
and combineWithAllErrors
into a synchronous version (behind the Result
namespace) and an asynchronous version (behind the ResultAsync
namespace).
So now we have:
Result.combine
Result.combineWithAllErrors
ResultAsync.combine
ResultAsync.combineWithAllErrors
... of course, this is a breaking change, and as such neverthrow
has now been bumped to version 5.0.0
Make `ResultAsync.fromPromise` and `ResultAsync.fromSafePromise` less strict!
Thanks to @bhvngt for this submission.
ResultAsync.fromPromise
and ResultAsync.fromSafePromise
are now able to accept anything that implements the PromiseLike
interface - in other words; anything that is "thenable". This includes objects such as Bluebird Promises and any other non-native promise-like object!
Fix issue when calling `combine` on proxies
User kieran-osgood submitted a fix for a long standing issue whereby proxies were suddenly disappearing within calls to combine
:
This issue is now resolved!
Additionally, the docs have been updated to reference eslint-plugin-neverthrow
.