Skip to content

Typings — flow-control

TypeScript interfaces and type aliases exported from @litert/utils-flow-control.

Import

ts
import type { ITryCatchOptions, ITryCatchResult } from '@litert/utils-flow-control';

Interface ITryCatchOptions

Source: TryCatch.ts

Options for the tryCatch function, describing the bodies of the try, catch, and optionally finally clauses.

Properties

PropertyTypeRequiredDescription
try() => TOkYesThe try body. May be synchronous or asynchronous.
catch(e: unknown) => TErrYesThe catch body. Receives the thrown error. May be synchronous or asynchronous. The finally clause still runs even if catch throws.
finally() => TFinalNoThe finally body. Must be synchronous. Runs after try or catch completes regardless of outcome. To avoid error-handling complexity, ensure this function does not throw.

Type Alias ITryCatchResult

Source: TryCatch.ts

A utility type that computes the exact return type of tryCatch based on the inferred types of TOk, TErr, and TFinal.

  • If any of TOk, TErr, or TFinal is a Promise, the result is a Promise of the appropriate union type.
  • If all three are synchronous, the result is a synchronous union type.

Definition

ts
type ITryCatchResult<TOk, TErr, TFinal> = /* complex conditional type */;

You rarely need to reference this type directly; TypeScript infers it automatically from the arguments you pass to tryCatch.