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
| Property | Type | Required | Description |
|---|---|---|---|
try | () => TOk | Yes | The try body. May be synchronous or asynchronous. |
catch | (e: unknown) => TErr | Yes | The catch body. Receives the thrown error. May be synchronous or asynchronous. The finally clause still runs even if catch throws. |
finally | () => TFinal | No | The 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, orTFinalis aPromise, the result is aPromiseof 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.