Skip to content

Type Alias: MatchCases<TValue, TError, TOkResult, TErrResult>

MatchCases<TValue, TError, TOkResult, TErrResult> = object

Defined in: src/types/methods.ts:19

Defines the execution branches for pattern matching.

See

ResultMethods.match - Pattern match a result.

Example

ts
const cases: MatchCases<number, string, string, string> = {
  ok: (val) => `Success: ${val}`,
  err: (err) => `Failed with: ${err}`
}

Type Parameters

Type ParameterDescription
TValueSuccess value type
TErrorError value type
TOkResultReturn type of the ok branch
TErrResultReturn type of the err branch

Properties

err

err: (error) => TErrResult

Defined in: src/types/methods.ts:38

Handles the error case.

Parameters

ParameterTypeDescription
errorTErrorError value

Returns

TErrResult

  • Value returned by the err branch

See

ResultMethods.match


ok

ok: (value) => TOkResult

Defined in: src/types/methods.ts:28

Handles the success case.

Parameters

ParameterTypeDescription
valueTValueSuccess value

Returns

TOkResult

  • Value returned by the ok branch

See

ResultMethods.match - Pattern match a result.