Typesafe, (almost) Zero Cost Dependency Injection in TypeScript

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • proposal-decorators

    Decorators for ES6 classes

    Unlike Java and C#, when TypeScript is transpiled to JavaScript the type information gets lost, making a TypeScript interface become nothing in JS. Because of this, it's not possible to use the interface itself as a token in the IoC Container. Decorators come in handy here to configure the service metadata in the Container.

  • tsyringe

    Lightweight dependency injection container for JavaScript/TypeScript

    tsyringe

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

  • fastify

    Fast and low overhead web framework, for Node.js

    Let's start with the example of REST APIs built over fastify:

  • typedi

    Simple yet powerful dependency injection tool for JavaScript and TypeScript.

    typedi

  • InversifyJS

    A powerful and lightweight inversion of control container for JavaScript & Node.js apps powered by TypeScript.

    inversify

  • injection-js

    Dependency injection library for JavaScript and TypeScript in 5.1K. It is an extraction of the Angular's ReflectiveInjector which means that it's well designed, feature complete, fast, reliable and well tested.

    injection-js

  • ioc

    :unicorn: lightweight (<1kb) inversion of control javascript library for dependency injection written in typescript (by owja)

    ioc

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • diod

    A very opinionated inversion of control (IoC) container and dependency injector for Typescript, Node.js or browser apps.

    diod

  • di-compiler

    A Custom Transformer for Typescript that enables compile-time Dependency Injection

    DI-compiler

  • typed-inject

    Type safe dependency injection for TypeScript

    typed-inject

  • dataloader

    DataLoader is a generic utility to be used as part of your application's data fetching layer to provide a consistent API over various backends and reduce requests to those backends via batching and caching.

    The one example of using Scoped dependency that comes to my mind, it's HTTP request level caching for libs like dataloader.

  • Note: You can find complete source code here.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts