Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Jul 3, 2025

This PR contains the following updates:

Package Change Age Confidence
typescript-result 3.1 -> 3.5 age confidence

Release Notes

everweij/typescript-result (typescript-result)

v3.5.2: 3.5.2

Compare Source

Fixes

  • See #​22 - Result.try and Result.fromAsyncCatching now catch exceptions that are thrown inside the transform-error callbacks.

Thanks @​PeterD1524 !

v3.5.1: 3.5.1

Compare Source

Fixes

  • See #​19 - Fixes issue where TS had trouble inferring the Result value when the shape of a value has some structural overlap with a Result type (e.g. { value: string }.

v3.5.0: 3.5.0

Compare Source

Minor changes:

  • Adds match() to Result, introducing basic pattern matching to the lib. See docs for more info about this feature.

     declare const result: Result<number, ErrorA | ErrorB>;
     
     if (!result.ok) {
       result
         .match()
         .when(ErrorA, () => /* handle error a */)
         .when(ErrorB, () => /* handle error b */)
         .run()
     }
  • Adds ok property on Result as the main way to check whether a result is a success or failure. See updated docs. This makes error handling a bit simpler, and allows us to more easily use a result with a pattern-matching lib like ts-pattern. As a result, isOk() and isError() are marked for deprecation.

    declare const result: Result<number, ErrorA | ErrorB>;
    
    // before
    if (result.isError()) {
      result.error; // ErrorA | ErrorB
    } else {
      result.value; // number
    }
    
    // after
    if (!result.ok) {
      result.error; // ErrorA | ErrorB
    } else {
      result.value; // number
    }
  • Strings passed to Result.error are now constant:

    // before
    const result = Result.error("some-error"); // Result.Error<string>
    
    // after
    const result = Result.error("some-error"); // Result.Error<"some-error">;

v3.4.1: 3.4.1

Compare Source

Fixes:

  • See #​18 - Due to an @internal annotation, the generator syntax (yield*, etc) wasn't working correctly. Removing the annotations on [Symbol.iterator]() solved the issue.

v3.4.0: 3.4.0

Compare Source

Minor Changes

  • See #​16: we better narrow Result.Ok / Result.Error when using Result.isOk() and Result.isError().

Fixes

  • See #​17: we now ignore any mapped values when a result can only be a failure, and likewise ignore the returned value when recovering from results that can only be successful.

v3.3.0: 3.3.0

Compare Source

Minor changes

  • adds optional transformErrorFn callback to Result.wrap
  • adds initial support for generator functions to create and work with results

v3.2.0: 3.2.0

Compare Source

Minor Changes

Result.fromAsync now also takes a callback function

Instead of only accepting a promise, you can use a callback function to create an AsyncResult instance:

function getUser(userId: string) {
  return Result.fromAsync(async () => {
    const user = await fetchUser(userId);
    
    if (!user) {
      return Result.error(new NotFoundError());
    }
    
    return Result.ok(user);
  });
}

This functionality is mainly a replacement for having to wrap the return of a function call in Result.fromAsync first, before being able to do any chaining. By using the callback variant of Result.fromAsync, the responsibility of transforming the async operation into an AsyncResult shifts from the consuming code to the source. Either way is fine, so it's mainly a matter of preference.

Result.recoverCatching and AsyncResult.recoverCatching now both have an optional transformError callback

Similar to what Result.mapCatching and AsyncResult.mapCatching already had, you can now transform any caught exceptions into a custom error:

declare const failedResult: Result<number, SomeError>;

const nextResult = failedResult.recoverCatching(
  () => {
      // logic skipped for brevity
      
      throw new Error("Boom")
  },
  (error) => new CustomError("Failed to recover", { cause: error }
);
Various improvements of types

Most notable are complex union types that now get merged into a single Result or AsyncResult:

type Before = Result<number, never> | Result<never, SomeError> | Result<number, SomeOtherError>

type After = Result<number, SomeError | SomeOtherError>;

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/typescript-result-3.x branch from e250754 to f91d608 Compare July 4, 2025 13:30
@renovate renovate bot changed the title fix(deps): update dependency typescript-result to 3.2 fix(deps): update dependency typescript-result to 3.3 Jul 4, 2025
@renovate renovate bot force-pushed the renovate/typescript-result-3.x branch from f91d608 to 7b9fbed Compare July 16, 2025 13:12
@renovate renovate bot changed the title fix(deps): update dependency typescript-result to 3.3 fix(deps): update dependency typescript-result to 3.4 Jul 16, 2025
@renovate renovate bot force-pushed the renovate/typescript-result-3.x branch from 7b9fbed to 800e137 Compare July 20, 2025 09:51
@renovate renovate bot changed the title fix(deps): update dependency typescript-result to 3.4 fix(deps): update dependency typescript-result to 3.5 Jul 20, 2025
@renovate renovate bot force-pushed the renovate/typescript-result-3.x branch from 800e137 to ff779fa Compare August 11, 2025 12:40
@renovate renovate bot force-pushed the renovate/typescript-result-3.x branch from ff779fa to 93f2679 Compare October 21, 2025 09:53
@renovate renovate bot force-pushed the renovate/typescript-result-3.x branch from 93f2679 to ff192b4 Compare November 10, 2025 21:33
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.

1 participant