
Effect-TS Has a Free API That Brings Typed Functional Effects to TypeScript
Effect is a TypeScript library for building complex, reliable applications. It brings typed errors, dependency injection, concurrency, and observability — all type-safe. Quick Start npm install effect Why Effect? Regular TypeScript: // What can go wrong? What does this need? No idea from the type. async function getUser ( id : string ): Promise < User > { ... } With Effect: // Types tell you: can fail with NotFound or DbError, needs DbClient function getUser ( id : string ): Effect < User , NotFound | DbError , DbClient > { ... } Basic Usage import { Effect , pipe } from ' effect ' const program = pipe ( Effect . succeed ( 42 ), Effect . map ( n => n * 2 ), Effect . tap ( n => Effect . log ( \ `Result: \$ {n} \` )) ) Effect.runPromise(program) // logs "Result: 84" Typed Errors class NotFound { readonly _tag = ' NotFound ' } class DbError { readonly _tag = ' DbError ' } const getUser = ( id : string ): Effect . Effect < User , NotFound | DbError > => pipe ( queryDb ( id ), Effect . catc
Continue reading on Dev.to JavaScript
Opens in a new tab

