Menu

Model “Couldn’t Check” as a Different State From Zero Results
📰

Model “Couldn’t Check” as a Different State From Zero Results

DEV Community: typescript·JEREMY NWOKORIE·9 days ago
#8xXqOzLN
#devtotypescript#devto#dev#queue#zero
Long article (365 words) — no AI summary yet.
Reading 0:00
15s threshold

From Primetime Home Health Services. Prepared with AI drafting assistance. This is a synthetic TypeScript example for a generic staff queue, not a live PTHHS screen or a decision about care, pay, or eligibility.

A dashboard that says “0 items” is making a claim: the last check succeeded and found none. If the request failed, a zero is the wrong default. The difference matters when an office is deciding whether anyone still needs to review the queue.

Make the difference explicit in the type

type Queue = | { kind : "checked" ; count : number ; at : string } | { kind : "stale" ; at : string } | { kind : "unavailable" } ;

function message ( s : Queue ) { switch ( s . kind ) { case "checked" : return `${s.count} items need review. Checked at ${s.at}.` ; case "stale" : return `Refresh failed. Last checked at ${s.at}; the earlier count may have changed.` ; case "unavailable" : return "Couldn’t check the list.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.