Skip to main content

Settled<T, E>

Package: antithrow

A narrowing of Result<T, E> that excludes Pending. Used wherever an API expects a result that has already finished.

Type

type Settled<T, E> = Ok<T, E> | Err<T, E>;
ParameterDescription
TThe success value type.
EThe error value type.

Where it appears

  • The resolved type of Pending<T, E>: PromiseLike<Settled<T, E>>.
  • The return type of settle(): PromiseLike<Settled<T, E>>.
  • The .result property on UnwrapError: Settled<unknown, unknown>.
  • InferOk — extracts T from a result type.
  • InferErr — extracts E from a result type.

InferOk

type InferOk<R> = R extends Result<infer T, unknown> ? T : never;

InferErr

type InferErr<R> = R extends Result<unknown, infer E> ? E : never;

Example

import { Result, type Settled } from "antithrow";

async function resolveConfig(
pending: Result<string, Error>,
): Promise<Settled<string, Error>> {
return await pending.settle();
}

See also

  • Result — the full union.
  • Pending — the shape that settles to Settled<T, E>.