microsoft

tsyringe: Inject Dependencies in TypeScript and JavaScript

TSyringe is a lightweight TypeScript and JavaScript dependency injection container for constructor injection. It resolves class dependencies at runtime and supports tokens, providers, scopes, and child containers.

View on GitHub Compare
Stars
6k
Forks
184
Stars, last 30 days
+3
Last commit
1 month ago
Contributors
25

Our take

Maintaineda few commits in the last 90 days

Health score

37/100

How it is scored
Activity
28
Community
56
Issues
21
Pull requests
43

+3 stars in the last 30 days

TSyringe is a focused option for TypeScript and JavaScript projects that want decorator-based constructor injection, with recent maintenance activity but no recent published release.

Good fit if

  • Your application uses TypeScript decorators and needs constructor injection with configurable providers and lifecycles.
  • You need token-based injection for interfaces or values, or want isolated child containers.
  • You are comfortable adopting a library whose health data shows a few recent commits and contributions from multiple contributors.

Look elsewhere if

  • You need property injection, which the project explicitly lists as a non-goal.
  • Your project cannot enable experimental decorators and emitted decorator metadata, or provide a Reflect polyfill.
  • Your adoption policy requires a recent release: the latest listed release is from 2020, despite recent repository activity.
All health signals
Last commit2026-09-08 (1 month ago)
Commits, last 90 days1
Releases, last 12 months0 (latest v4.4.0, 2020-11-09)
Contributors25 (top contributor: 60% of commits)
Issues closed, last 90 days0
Pull requests merged, last 90 days1
Project age8 years

Checked on 2026-10-16 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

6,016

Forks

186

Change since Nov 22, 2026: +1 stars·+1 forks

Overview

TSyringe is a lightweight dependency injection container for TypeScript and JavaScript, built around constructor injection. It helps applications provide classes with their dependencies through a container, rather than requiring each class to construct those dependencies itself.

It uses TypeScript decorator metadata to resolve class dependencies automatically. For interfaces and other types that do not exist at runtime, developers register injection tokens and use decorators to connect them to providers. The project is a library for Node.js and JavaScript/TypeScript applications, not a standalone service or framework.

Key Features

  • Resolves decorated classes and their constructor dependencies from a container.
  • Supports injection tokens for interfaces, primitives, and other runtime-invisible types.
  • Offers transient, singleton, resolution-scoped, and container-scoped lifecycles.
  • Provides class, value, factory, and token-alias providers, including factories with caching.
  • Supports resolving multiple registrations for a token and transforming injected values.
  • Allows child containers with their own registrations and fallback resolution from a parent.
  • Includes interception callbacks, circular-dependency support through delay, and disposal of disposable instances.

Use Cases

  • A TypeScript application can resolve services and repositories through constructor injection rather than wiring every dependency by hand.
  • A codebase using interfaces can register implementations under tokens and inject those implementations into consumers.
  • A server can create child containers for separate request contexts while sharing common registrations from a parent.
  • Tests can clear cached instances between runs while keeping registrations in place.

What you need

Detected in the repository

  • Node.js >= 6.0.0 (from package.json)
  • A test suite and automated checks on GitHub Actions

License in plain words

MITpermissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the copyright and license notice
  • Share your changes: no

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

Install the package:

npm install --save tsyringe

Enable experimentalDecorators and emitDecoratorMetadata in tsconfig.json, and load a Reflect polyfill such as reflect-metadata before using dependency injection. See the README for configuration and API examples.

Considerations

  • The health data reports no releases in the past year and a latest release from 2020. The repository is not archived and has had a few commits recently, but release recency may matter for teams that require versioned updates.
  • The measured data shows no issues closed in the last 90 days and one merged pull request in that period. It also lists 25 contributors, with no contributor-concentration warning.
  • The package requires Node.js 6 or later according to its package metadata. TypeScript consumers must configure decorator metadata and load a Reflect polyfill before dependency injection is used.
  • Circular dependencies can be handled with delay, but the README recommends refactoring to remove cycles when possible. Property injection is explicitly out of scope.

Found this useful?

Share it with someone who would like tsyringe.