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.
// 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:
- Documentation gap — Users reading
IResultto understand the API won't discoverasyncAndThrough - Contract inconsistency — The interface is the spec; implementing a method without declaring it in the interface is a design inconsistency
- Subclass risk — Anyone extending
OkorErrand relying onIResultas 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:
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 |
❌ | ✅ | ✅ |
Source: supermacro/neverthrow