Result type

A type, usually a discriminated union, that holds either a successful value or an error, so failures are part of the return type.

In more detail

type TaskResult = { ok: true; task: Task } | { ok: false; error: ProblemDetails } forces callers to check ok before using task. An Option type similarly holds either a value or nothing. Both are built with generic type aliases.

Related terms

Taught in

References