type alias Tried
Private

Caught for a synchronous source, a never-rejecting Promise<Caught> for an async one.

The first arm handles an any-typed source — JSON.parse, the flagship caller. A conditional type applied to any resolves to the union of both branches, which would hand the caller the unusable Promise<Caught> | Caught (no .ok until narrowed by hand). 0 extends 1 & T is true only for any; such a source is treated as synchronous and its value as unknown — the honest reading of any, and what the call site can branch on.

Type Parameters

Definition

0 extends 1 & T ? Caught<unknown> : [T] extends [PromiseLike<unknown>] ? Promise<Caught<Awaited<T>>> : Caught<T>

Usage

import { type Tried } from "lib/result/try.ts";