Skip to content

Deferred

Deferred<A> = object

Defined in: Core/Deferred.ts:22

A nominally typed, one-shot async value that supports await but enforces infallibility.

Two design choices work together to make the guarantee structural rather than documentary:

  • The phantom [_deferred] symbol makes the type nominal: only values produced by Deferred.fromPromise satisfy it. A plain object { then: ... } does not.
  • The single-parameter .then() excludes rejection handlers by construction. There is no second argument to pass, so chaining and .catch() are impossible.

This makes Deferred<A> the natural return type for Task<A>, which is guaranteed to never reject.

const value = await Deferred.fromPromise(Promise.resolve(42));
// value === 42

A

readonly [_deferred]: A

Defined in: Core/Deferred.ts:23


readonly then: (onfulfilled) => void

Defined in: Core/Deferred.ts:24

(value) => void

void