strictcli v0.39.0 /typescript/src/outcome
On this page

Handler outcome: the branded structured-result type plus the strict interpretation of handler return values, mirroring the Python Outcome semantics.

#typescript/src/outcome

#typescript/src/outcome

Handler outcome: the branded structured-result type plus the strict interpretation of handler return values, mirroring the Python Outcome semantics. Python's Outcome/outcome()/_interpret_handler_return is the divergence ground truth; Go's type system makes bad returns inexpressible.

Data JSON serialization lives here too: one compact line, BigInt values as bare integer tokens (JSON.stringify cannot emit those, hence the custom serializer). Map keys are emitted sorted (the TS dict type mirrors Go maps, which json.Marshal sorts); plain objects keep insertion order (mirroring Python dicts under json.dumps).

#Outcome

TS typescript
export interface Outcome

A structured result returned by a command handler. Built exclusively via the outcome() factory -- the mint set is module-private, so hand-forged objects are never recognized as outcomes (no structural shape detection).

#outcome

TS typescript
export function outcome(exitCode = 0, data?: unknown): Outcome

Builds an Outcome for a command handler to return. exitCode defaults to 0. When data is not undefined/null it is JSON-printed to stdout as one compact line and captured by test()/call().

#isOutcome

TS typescript
export function isOutcome(v: unknown): v is Outcome

#InterpretedReturn

TS typescript
export interface InterpretedReturn

Interpreted handler return: exit code plus the optional data payload.

#interpretHandlerReturn

TS typescript
export function interpretHandlerReturn(result: unknown): InterpretedReturn

Maps a command handler's (awaited) return value to exit code + data. The only permitted returns are an integer number (exit code), undefined (exit 0), or an outcome() -- anything else is a hard error (TypeError), mirroring Python's _interpret_handler_return.

#jsonCompact

TS typescript
export function jsonCompact(value: unknown): string

Serializes outcome data as one compact JSON line (no whitespace). BigInt values become bare integer tokens; Maps become objects with sorted keys; plain objects keep insertion order and skip undefined-valued properties (JSON.stringify semantics).

Search