Type contracts: IResult, IOption
Result type definitions — barrel export.
Re-exports all discriminated union type interfaces. Its only runtime export is an empty default object, which keeps this entry and its sourcemap materialized.
Interfaces
Section titled “Interfaces”AsyncOption
Section titled “AsyncOption”Defined in: types/AsyncOption.ts:14
AsyncOption — a lazy asynchronous option.
Represents a computation that will produce a IOption<T> when .run() is called.
This enables deferred/lazy composition of optional operations without executing them eagerly.
AsyncOption is a lazy thunk wrapping () => Promise<IOption<T>>.
Call run() to execute the computation.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Description |
|---|---|
T |
— The value type. |
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
run |
readonly |
() => Promise<IOption<T>> |
AsyncResult
Section titled “AsyncResult”Defined in: types/AsyncResult.ts:15
AsyncResult — a lazy asynchronous result.
Represents a computation that will produce a IResultOfT<T, E> when .run() is called.
This enables deferred/lazy composition of async operations without executing them eagerly.
AsyncResult is a lazy thunk wrapping () => Promise<IResultOfT<T, E>>.
Call run() to execute the computation.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type | Description |
|---|---|---|
T |
- | — The success value type. |
E |
unknown |
— The error type. Defaults to unknown (matches IResultOfT). |
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
run |
readonly |
() => Promise<IResultOfT<T, E>> |
IOptionNone
Section titled “IOptionNone”Defined in: types/Option.ts:13
IOptionNone — the None variant of IOption.
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
isNone |
readonly |
true |
isSome |
readonly |
false |
IOptionSome
Section titled “IOptionSome”Defined in: types/Option.ts:4
IOptionSome — the Some variant of IOption.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
isNone |
readonly |
false |
isSome |
readonly |
true |
value |
readonly |
T |
IResultFailure
Section titled “IResultFailure”Defined in: types/IResult.ts:22
IResultFailure — the failure variant of IResult.
Carries the error. The isSuccess: false literal discriminates this
variant within the IResult union, enabling TypeScript narrowing.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type | Description |
|---|---|---|
TError |
unknown |
— The error type. Defaults to unknown because the library never silently coerces an unknown thrown value to a specific shape — callers must narrow or supply an errorFn to take responsibility for the type. |
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
error |
readonly |
TError |
isFailure |
readonly |
true |
isSuccess |
readonly |
false |
IResultOfTFailure
Section titled “IResultOfTFailure”Defined in: types/IResultOfT.ts:16
IResultOfTFailure — the failure variant of IResultOfT.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type | Description |
|---|---|---|
TError |
unknown |
— The error type. Defaults to unknown because the library never silently coerces an unknown thrown value to a specific shape. |
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
error |
readonly |
TError |
isFailure |
readonly |
true |
isSuccess |
readonly |
false |
IResultOfTSuccess
Section titled “IResultOfTSuccess”Defined in: types/IResultOfT.ts:4
IResultOfTSuccess — the success variant of IResultOfT.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
TValue |
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
isFailure |
readonly |
false |
isSuccess |
readonly |
true |
value |
readonly |
TValue |
IResultSuccess
Section titled “IResultSuccess”Defined in: types/IResult.ts:7
IResultSuccess — the success variant of IResult.
Carries no error. The isSuccess: true literal discriminates this
variant within the IResult union, enabling TypeScript narrowing.
Properties
Section titled “Properties”| Property | Modifier | Type |
|---|---|---|
isFailure |
readonly |
false |
isSuccess |
readonly |
true |
Type Aliases
Section titled “Type Aliases”IOption
Section titled “IOption”IOption<
T> =IOptionSome<T> |IOptionNone
Defined in: types/Option.ts:36
IOption — the optional value discriminated union.
An optional value is either a Some (IOptionSome, carrying
value) or a None (IOptionNone, no value).
Check isSome to narrow before accessing value:
if (option.isSome) { console.log(option.value); // safe — narrowed to Some} else { // option.value — type error: not on None variant}Type Parameters
Section titled “Type Parameters”| Type Parameter | Description |
|---|---|
T |
— The contained value type. |
IResult
Section titled “IResult”IResult<
TError> =IResultSuccess|IResultFailure<TError>
Defined in: types/IResult.ts:46
IResult — the void result discriminated union.
A result is either a success (IResultSuccess, no error) or a failure (IResultFailure, carrying the error).
Check isSuccess to narrow before accessing error:
if (result.isSuccess) { // result.error — type error: not on the success variant} else { console.log(result.error); // safe — narrowed to failure}Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type | Description |
|---|---|---|
TError |
unknown |
— The error type. Defaults to unknown. |
IResultOfT
Section titled “IResultOfT”IResultOfT<
TValue,TError> =IResultOfTSuccess<TValue> |IResultOfTFailure<TError>
Defined in: types/IResultOfT.ts:42
IResultOfT — the value-bearing result discriminated union.
A value-bearing result is either a success (IResultOfTSuccess,
carrying value) or a failure (IResultOfTFailure, carrying
error).
Check isSuccess to narrow before accessing value or error:
if (result.isSuccess) { console.log(result.value); // safe — narrowed to success} else { console.log(result.error); // safe — narrowed to failure}Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type | Description |
|---|---|---|
TValue |
- | — The success value type. |
TError |
unknown |
— The error type. Defaults to unknown. |
Variables
Section titled “Variables”default
Section titled “default”default:
object
Defined in: types/index.ts:21