Skip to content
Sarj Code Standards

no-discarded-tagged-outcome

Consume a closed tagged success or failure outcome instead of discarding it.

Why

A returned failure channel cannot protect a caller that discards the whole outcome; awaiting a promise alone does not inspect its result.

Fix

Capture or return the outcome and handle its declared failure variant. Keep ordinary side-effect calls and throwing APIs unchanged.

Examples

Before — flagged Detect the demonstrated gap
app.ts
type Outcome = { ok: true; value: string } | { ok: false; error: string };
function save(): Outcome {
return { ok: true, value: "saved" };
}
save();
After — preferred Preserve the declared boundary
app.ts
type Outcome = { ok: true; value: string } | { ok: false; error: string };
function save(): Outcome {
return { ok: true, value: "saved" };
}
const result = save();
if (!result.ok) report(result.error);