
Effect Has a Free API — Type-Safe Error Handling for TypeScript
Effect is a TypeScript library for building robust, type-safe applications with structured concurrency, typed errors, and dependency injection. Think of it as Rust's Result type meets Go's goroutines — in TypeScript. Why Effect? Typed errors — know exactly what can fail at compile time Dependency injection — built-in, type-safe service layer Structured concurrency — fibers, interruption, resource management Retry, timeout, caching — all composable and type-safe Quick Start npm install effect import { Effect } from ' effect ' ; // An effect that can fail with string or succeed with number const divide = ( a : number , b : number ): Effect . Effect < number , string > => b === 0 ? Effect . fail ( ' Division by zero ' ) : Effect . succeed ( a / b ); // Run it const result = Effect . runSync ( divide ( 10 , 2 )); // 5 // Handle errors const program = divide ( 10 , 0 ). pipe ( Effect . catchAll (( error ) => Effect . succeed ( - 1 )) ); Typed Error Channel class NetworkError { readonly _tag
Continue reading on Dev.to JavaScript
Opens in a new tab


