Typed errors with async/await
You want compile-time error checking without giving up familiar syntax
Good things come to those who a-wait-ly
Result<T, E> instead of try/catchnpm install awaitlyimport { ok, err, type AsyncResult } from 'awaitly';import { createWorkflow } from 'awaitly/workflow';
// Define operations that return Results (or use Awaitly.ok / Awaitly.err)const fetchUser = async (id: string): AsyncResult<User, 'NOT_FOUND'> => id === '1' ? ok({ id, name: 'Alice' }) : err('NOT_FOUND');
// Create workflow - error types are inferredconst workflow = createWorkflow('workflow', { fetchUser });
// Run itconst result = await workflow.run(async ({ step, deps }) => { const user = await step('fetchUser', () => deps.fetchUser('1')); return user;});
if (result.ok) { console.log(result.value.name);} else { // TypeScript knows: result.error is 'NOT_FOUND' | UnexpectedError}Typed errors with async/await
You want compile-time error checking without giving up familiar syntax
Reliability primitives
You need retries, timeouts, circuit breakers built into your workflow
Long-running workflows
You’re building workflows that pause for approval or persist across restarts
Automatic error inference
You want error types computed from dependencies, not maintained manually