asyncAndThrough is implemented on Ok/Err but missing from IResult interface

Author: BinilkksCreated Jun 26, 2026Updated Jun 26, 2026

Bug: asyncAndThrough not declared in IResult interface

Problem

Both Ok and Err implement asyncAndThrough, but it is not declared in the IResult interface.

typescript
// src/result.ts

interface IResult<T, E> {
  // ...
  andThrough<R>(f: (t: T) => R): Result<T, ...>   // ✅ declared
  asyncAndThen<U, F>(f): ResultAsync<U, E | F>     // ✅ declared
  asyncMap<U>(f): ResultAsync<U, E>                // ✅ declared
  // asyncAndThrough — ❌ MISSING
}

class Ok<T, E> implements IResult<T, E> {
  asyncAndThrough<F>(f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>  // implemented
}

class Err<T, E> implements IResult<T, E> {
  asyncAndThrough<F>(_f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F> // implemented
}

Why it matters

IResult is the authoritative API contract for Result. If asyncAndThrough is not in the interface:

  1. Documentation gap — Users reading IResult to understand the API won't discover asyncAndThrough
  2. Contract inconsistency — The interface is the spec; implementing a method without declaring it in the interface is a design inconsistency
  3. Subclass risk — Anyone extending Ok or Err and relying on IResult as a guide would miss this method

The pattern is already broken for asyncAndThrough specifically

IResult declares asyncAndThen and asyncMap (the async equivalents of andThen and map), so the expectation is that asyncAndThrough (the async equivalent of andThrough) should also be declared there.

Fix

Add asyncAndThrough to the IResult interface:

typescript
interface IResult<T, E> {
  // ... existing methods ...
  andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>
  andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>

  // Add this:
  asyncAndThrough<R extends ResultAsync<unknown, unknown>>(
    f: (t: T) => R,
  ): ResultAsync<T, InferAsyncErrTypes<R> | E>
  asyncAndThrough<F>(f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>
}

Consistency Table

Method In IResult In Ok In Err
andThrough
asyncAndThen
asyncMap
asyncAndThrough