Developer builds better-effect to bring type-safe dependency injection to TypeScript
A developer created better-effect, a TypeScript library, after finding that typed errors alone were insufficient to prevent runtime failures caused by missing dependencies. While typed Result types clearly describe success and failure outcomes, they do not capture what services or resources an operation requires to run. The new library allows dependencies to be declared directly inside generator-based effects using a yield* syntax, making requirements visible at the type level. If any required service is missing when assembling the application runtime, TypeScript rejects the code at compile time rather than allowing a startup crash. The approach, which the author calls typechecked wiring, keeps service definitions, implementations, and runtime configuration in sync without a separate dependency list.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in