DEV Community

Alex Spinov
Alex Spinov

Posted on

Effect-TS Has a Free TypeScript Standard Library — Production-Grade Error Handling and Concurrency

A TypeScript developer tried to handle errors properly. Try/catch everywhere, forgotten error cases, no way to know what a function can throw from its type signature.

Effect is a TypeScript library that makes errors, async, and concurrency type-safe. Think of it as a production-grade standard library for TypeScript.

What Effect Offers for Free

  • Typed Errors - Errors in the type signature, not hidden in throws
  • Concurrency - Structured concurrency with fibers
  • Dependency Injection - Built-in DI without frameworks
  • Retries - Configurable retry policies
  • Scheduling - Cron, intervals, delays
  • Streaming - Backpressured streaming
  • Tracing - OpenTelemetry integration
  • Schema - Runtime validation with type inference (like Zod but more powerful)

Quick Start

import { Effect, pipe } from 'effect'

const fetchUser = (id: string) =>
  Effect.tryPromise({
    try: () => fetch(\`/api/users/\${id}\`).then(r => r.json()),
    catch: () => new Error('NetworkError'),
  })

const program = pipe(
  fetchUser('1'),
  Effect.retry({ times: 3 }),
  Effect.timeout('5 seconds'),
)

Effect.runPromise(program)
Enter fullscreen mode Exit fullscreen mode

GitHub: Effect-TS/effect - 8K+ stars


Need to monitor and scrape data from multiple web services automatically? I build custom scraping solutions. Check out my web scraping toolkit or email me at spinov001@gmail.com for a tailored solution.

Top comments (0)