# microsoft/tsyringe

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/microsoft-tsyringe).**

5,960 stars · 182 forks · TypeScript · MIT

## Links

- GitHub: https://github.com/microsoft/tsyringe
- awesome-repositories: https://awesome-repositories.com/repository/microsoft-tsyringe.md

## Topics

`container` `decorators` `dependency` `dependency-injection` `injection` `ioc` `typescript`

## Description

tsyringe is a TypeScript dependency injection container and inversion of control framework. It decouples class implementations from object creation by managing dependencies and object lifecycles using decorators and metadata.

The framework features a hierarchical container system where child containers can maintain independent registration scopes and fall back to parent containers for dependency resolution. It provides a provider system that controls object longevity through singleton and transient instantiation rules.

The system supports recursive constructor injection and handles circular dependencies using proxies. It includes capabilities for token-based registry mapping, multi-implementation resolution, and automated resource disposal for objects that implement cleanup interfaces.

## Tags

### Software Engineering & Architecture

- [TypeScript Dependency Injection Libraries](https://awesome-repositories.com/f/software-engineering-architecture/cross-platform-development/multiplatform-code-sharing/typescript-dependency-injection-libraries.md) — Provides a full-featured dependency injection library tailored for TypeScript, leveraging decorators and metadata for runtime injection.
- [Class Registries](https://awesome-repositories.com/f/software-engineering-architecture/class-registries.md) — Maintains centralized mappings of tokens to provider definitions for dynamic lookup and instantiation.
- [Dependency Injection Frameworks](https://awesome-repositories.com/f/software-engineering-architecture/dependency-injection-frameworks.md) — Functions as a comprehensive inversion of control framework that decouples class implementations from their instantiation logic.
- [Automatic Constructor Injection](https://awesome-repositories.com/f/software-engineering-architecture/dependency-injection-providers/automatic-constructor-injection.md) — Provides automatic provisioning of dependencies into constructors using metadata and annotations. ([source](https://github.com/microsoft/tsyringe/blob/master/README.md))
- [Dependency Resolution](https://awesome-repositories.com/f/software-engineering-architecture/dependency-resolution.md) — Provides the process of retrieving and instantiating registered services from a container using unique tokens. ([source](https://github.com/microsoft/tsyringe#readme))
- [Instance Lifecycles](https://awesome-repositories.com/f/software-engineering-architecture/instance-lifecycles.md) — Controls object longevity through singleton and transient instantiation rules.
- [Dependency Metadata](https://awesome-repositories.com/f/software-engineering-architecture/metadata-attachments/decorator-based/dependency-metadata.md) — Uses TypeScript decorators to store dependency requirements in class metadata for runtime retrieval.
- [Instance Lifecycles](https://awesome-repositories.com/f/software-engineering-architecture/object-instantiation-restrictions/singleton-patterns/instance-lifecycles.md) — Provides a provider system to control object longevity via singleton and transient instantiation rules.
- [Recursive Dependency Resolution](https://awesome-repositories.com/f/software-engineering-architecture/recursive-dependency-resolution.md) — Resolves a graph of nested constructor dependencies recursively until a base instance is created.
- [Provider Mappings](https://awesome-repositories.com/f/software-engineering-architecture/service-instance-managers/automatic-service-registrations/automatic-dependency-registrations/provider-mappings.md) — Links tokens to classes, values, or factories to define how the container creates dependencies. ([source](https://github.com/microsoft/tsyringe/blob/master/README.md))
- [Circular Dependency Resolution](https://awesome-repositories.com/f/software-engineering-architecture/dependency-resolution-engines/circular-dependency-resolution.md) — Implements techniques for deferring component resolution to handle circular module dependencies. ([source](https://github.com/microsoft/tsyringe/blob/master/README.md))
- [Dependency State Management](https://awesome-repositories.com/f/software-engineering-architecture/dependency-state-management.md) — Manages shared resources by defining dependencies as singletons or transient instances.
- [Modular Software Design](https://awesome-repositories.com/f/software-engineering-architecture/modular-software-design.md) — Provides a foundation for modular software design through token-based registration and decoupled component organization.
- [Container Shutdown Cleanup](https://awesome-repositories.com/f/software-engineering-architecture/observer-patterns/disposable-observers/automatic-subscription-disposals/container-shutdown-cleanup.md) — Triggers cleanup methods on all objects implementing a disposable interface during container shutdown. ([source](https://github.com/microsoft/tsyringe/blob/master/README.md))
- [Proxy-Based Resolution](https://awesome-repositories.com/f/software-engineering-architecture/proxy-based-resolution.md) — Provides proxy objects that resolve dependencies lazily to break circular dependency loops.

### Data & Databases

- [Dependency Lifecycle Management](https://awesome-repositories.com/f/data-databases/resource-management/resource-lifecycle-managers/dependency-lifecycle-management.md) — Manages the acquisition and release phases of dependencies to control object longevity. ([source](https://github.com/microsoft/tsyringe/blob/master/src/types/registration-options.ts))
- [Dependency Resource Disposal](https://awesome-repositories.com/f/data-databases/resource-management/resource-lifecycle-managers/dependency-resource-disposal.md) — Executes registered cleanup functions for dependencies to release system resources.
- [Disposable Resource Management](https://awesome-repositories.com/f/data-databases/resource-management/resource-lifecycle-managers/disposable-resource-management.md) — Automates the cleanup of memory and connections by triggering disposal methods on container-managed objects.

### DevOps & Infrastructure

- [Hierarchical Containers](https://awesome-repositories.com/f/devops-infrastructure/dependency-management/dependency-injection-systems/service-containers/hierarchical-containers.md) — Ships a hierarchical container system where child containers maintain independent scopes and fall back to parent containers.

### Development Tools & Productivity

- [Circular Dependency Resolvers](https://awesome-repositories.com/f/development-tools-productivity/dependency-resolvers/bean-resolution-strategies/circular-dependency-resolvers.md) — Implements mechanisms to break circular dependency loops by providing partially initialized references during object instantiation.

### Operating Systems & Systems Programming

- [Resource Cleanup Utilities](https://awesome-repositories.com/f/operating-systems-systems-programming/resource-cleanup-utilities.md) — Provides utilities for ensuring the deterministic release of system resources during object destruction. ([source](https://github.com/microsoft/tsyringe/blob/master/src/types/disposable.ts))
