Typesafe, (almost) Zero Cost Dependency Injection in TypeScript

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

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. 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.

  2. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  3. tsyringe

    Lightweight dependency injection container for JavaScript/TypeScript

    tsyringe

  4. fastify

    Fast and low overhead web framework, for Node.js

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

  5. typedi

    Simple yet powerful dependency injection tool for JavaScript and TypeScript.

    typedi

  6. InversifyJS

    Powerful and lightweight inversion of control container. Moved to https://github.com/inversify/monorepo

    inversify

  7. 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

  8. ioc

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

    ioc

  9. diod

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

    diod

  10. di-compiler

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

    DI-compiler

  11. typed-inject

    Type safe dependency injection for TypeScript

    typed-inject

  12. 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.

  13. 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

  • Top 5 TypeScript dependency injection containers

    6 projects | dev.to | 29 Jul 2021
  • The 6th SOLID Principle?

    1 project | dev.to | 20 Mar 2026
  • The SOLID Principles are Universal

    1 project | dev.to | 20 Mar 2026
  • Mastering the Dependency Inversion Principle: Best Practices for Clean Code with DI

    2 projects | dev.to | 28 Nov 2024
  • How to Apply SOLID with Testing JS/TS Class Methods

    1 project | dev.to | 13 Jan 2024

Did you know that TypeScript is
the 2nd most popular programming language
based on number of references?