Skip to main content

Changelog

A comprehensive history of changes, improvements, and bug fixes in NeverThrow.

v8.2.0 (Current)

Minor Changes

Pull Request: #615
Contributor: @konker
Added orTee, which is the equivalent of andTee but for the error track. This method allows you to perform side effects on error values without affecting the Result’s error type.Example:
import { parseUserInput } from 'imaginary-parser'
import { logParseError } from 'imaginary-logger'
import { insertUser } from 'imaginary-database'

const resAsync = parseUserInput(userInput)
  .orTee(logParseError)  // Log errors without affecting the Result
  .asyncAndThen(insertUser)

// Note: No LogError appears in the Result type
Pull Request: #584
Contributor: @macksal
The ok, err, okAsync, and errAsync functions now accept zero arguments when returning void.Example:
// Now valid:
const result: Result<void, never> = ok()
const error: Result<never, void> = err()
const asyncResult: ResultAsync<void, never> = okAsync()
const asyncError: ResultAsync<never, void> = errAsync()

v8.1.1

Patch Changes

Pull Request: #600
Contributor: @m-shaka
Updated README.md documentation about safeTry and added @deprecated tag to safeUnwrap.

v8.1.0

Minor Changes

Pull Request: #589
Contributor: @dmmulroy
safeTry no longer requires calling .safeUnwrap() on Results within the generator function. You can now use yield* directly on Result values.Before:
function myFunc(): Result<number, string> {
  return safeTry<number, string>(function*() {
    const value = yield* mayFail().safeUnwrap()  // Had to call safeUnwrap
    return ok(value * 2)
  })
}
After:
function myFunc(): ResultAsync<number, string> {
  return safeTry<number, string>(function*() {
    const value = yield* mayFail()  // No safeUnwrap needed
    return ok(value * 2)
  })
}

v8.0.0

Major Changes

Pull Request: #484
Contributor: @braxtonhall
The orElse method now allows changing ok types, making the types match the implementation.Breaking Change:The ok type must now be provided before the err type when explicitly providing type arguments.
- result.orElse<ErrType>(foo)
+ result.orElse<OkType, ErrType>(foo)
Migration:This only applies if type arguments were explicitly provided at an orElse callsite. If the type arguments were inferred, no updates are needed during the upgrade.

v7.2.0

Minor Changes

Pull Request: #562
Contributor: @sharno
Changed the return type of safeTry from Promise<Result<T, E>> to ResultAsync<T, E> for better composability.What This Means:ResultAsync is thenable and behaves like a native Promise, but provides additional methods like map, andThen, and mapErr without needing to await or .then() first.Example:
// Now you can chain directly
safeTry(async function* () {
  // ...
})
  .map(x => x * 2)
  .andThen(processValue)
  .match(
    (value) => console.log(value),
    (error) => console.error(error)
  )

v7.1.0

Minor Changes

Pull Request: #467
Contributor: @untidy-hair
Added andTee and andThrough methods to handle side effects:
  • andTee: Perform side effects without affecting the Result type (errors are ignored)
  • andThrough: Validate or perform checks where errors should propagate
Example:
// andTee for logging (errors ignored)
parseUserInput(userInput)
  .andTee(logUser)
  .asyncAndThen(insertUser)

// andThrough for validation (errors propagated)
parseUserInput(userInput)
  .andThrough(validateUser)
  .asyncAndThen(insertUser)

Patch Changes

Pull Request: #483
Contributor: @braxtonhall
Fixed type definitions for combineWithAllErrors to properly handle error arrays.
Pull Request: #563
Contributor: @mattpocock
Made err() infer strings narrowly for easier error tagging.Example:
// Error type is inferred as 'NotFound' (not generic string)
const notFound = err('NotFound')

// Useful for pattern matching
if (result.isErr()) {
  switch (result.error) {
    case 'NotFound':
      return 404
    case 'Unauthorized':
      return 401
    default:
      return 500
  }
}

v7.0.1

Patch Changes

Pull Request: #527
Contributor: @3846masa
Changed type definitions to make inferring types of safeTry more strict and accurate.
Pull Request: #497
Contributor: @braxtonhall
Enhanced type inference for the match method to better handle callback return types.

v7.0.0

Major Changes

Pull Request: #553
Contributor: @m-shaka
Declared the minimum supported Node.js version in the engines field of package.json.Requirements:
  • Node.js: >=18
  • npm: >=11
Note:NeverThrow does not depend on any Node.js version-specific features, so it should work with any version of Node.js that supports ES6 and other runtimes like browsers, Deno, etc.The engine declaration is primarily for maintaining a consistent development environment.

Earlier Versions

For a complete history of changes in versions prior to v7.0.0, please visit the GitHub releases page.

Release Channels

NeverThrow follows semantic versioning:
  • Major versions (x.0.0) contain breaking changes
  • Minor versions (0.x.0) add new features in a backward-compatible manner
  • Patch versions (0.0.x) contain bug fixes and documentation updates

Stay Updated

Contributing

Interested in contributing to NeverThrow?

Support the Project

If you find NeverThrow useful:

Build docs developers (and LLMs) love