Represent success and failure without throwing.
Section: Async and Promise Types
Model a result union
typescript
typescript
type Ok<T> = { ok: true; value: T };
type Err = { ok: false; error: string };
type Result<T> = Ok<T> | Err;Explanation
Result unions are a clean pattern for app code that wants explicit error handling.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Async and Promise Types
Type an async function
Return a typed promise from an async function.
Narrow with `instanceof`
Refine class-based unions using constructor checks.