type alias Of

The Failure type a factory produces: Failure.Of<typeof FileMissing>.

Lets a function signature name its failure modes by pointing at the declarations rather than restating their code and payload:

import * as Failure from './failure.ts';
import * as Result from './result.ts';

const GitScanFailed = Failure.define('GitScanFailed', (d: { ref: string }) => `bad ref: ${d.ref}`);
type GitScanFailure = Failure.Of<typeof GitScanFailed>;
//   ^? Failure<'GitScanFailed', { ref: string }>
const scan = (ref: string): Result.Result<string[], GitScanFailure> =>
  GitScanFailed({ ref }); // the failure IS the Result's failure arm — no wrapper

Type Parameters

Definition

F extends FailureFactory<infer Code, infer Data> ? Failure<Code, Data> : never

Usage

import { type Of } from "lib/result/failure.ts";