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 Parameter | Description |
|---|---|
TValue | Success value type |
TError | Error value type |
TOkResult | Return type of the ok branch |
TErrResult | Return type of the err branch |
Properties
err
err: (
error) =>TErrResult
Defined in: src/types/methods.ts:38
Handles the error case.
Parameters
| Parameter | Type | Description |
|---|---|---|
error | TError | Error value |
Returns
TErrResult
- Value returned by the
errbranch
See
ok
ok: (
value) =>TOkResult
Defined in: src/types/methods.ts:28
Handles the success case.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | TValue | Success value |
Returns
TOkResult
- Value returned by the
okbranch
See
ResultMethods.match - Pattern match a result.