Menu

Model an Unknown Return Time Without Turning It Into a Booking
📰

Model an Unknown Return Time Without Turning It Into a Booking

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

Adapted from Ride Primetime’s company article. Prepared with AI drafting assistance. The code and tests below are synthetic design examples, not deployed dispatch behavior.

A rider needs to reach a building by 9 a.m. They need a ride home, but the appointment end time is unknown. If the input is just an optional return time, a blank could mean one way, return needed with no time yet, or a field the rider skipped. Those meanings should not share one value.

Capture what the rider knows

Use a tagged union. A one-way request has no return time. A discussed-later return intentionally has no time. A timed return has a time. Keep these as request facts. Availability and agreement are separate evidence from the provider.

type ReturnPlan = | { kind : "one-way" } | { kind : "return-time-unknown" } | { kind : "return-time-requested" ; at : string } ;

type Confirmation = { outbound : boolean ; return : boolean } ;

function summary ( plan : ReturnPlan , confirmed : Confirmation ) { const outbound = confirmed .…

Continue reading — create a free account

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