git404hub

what is tsyringe fr?

microsoft/tsyringe — explained in plain English

Analysis updated 2026-06-26

5,947TypeScriptAudience · developerComplexity · 3/5LicenseSetup · moderate

tl;dr

TSyringe is a lightweight dependency injection library from Microsoft for TypeScript that uses decorators to automatically wire together class dependencies through a central container at runtime.

vibe map

mindmap
  root((TSyringe))
    What it does
      Dependency injection
      Auto-wire classes
      Central container
    Decorators
      injectable
      singleton
      inject
    Container features
      Register class or value
      Child containers
      Scoped lifetimes
    Setup
      tsconfig changes
      Reflect polyfill
      npm install

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

what do people make with this?

VIBE 1

Replace manual class instantiation in a TypeScript app with a container that automatically creates and injects dependencies

VIBE 2

Make TypeScript services easier to unit test by swapping real implementations for mocks in the container

VIBE 3

Enforce singleton instances of shared services like a database connection so only one instance ever exists

VIBE 4

Use child containers to scope dependencies to a specific request or operation lifecycle in a server app

what's the stack?

TypeScriptJavaScriptNode.js

how it stacks up fr

microsoft/tsyringelucaong/minisearchgooglechrome/rendertron
Stars5,9475,9505,951
LanguageTypeScriptTypeScriptTypeScript
Setup difficultymoderateeasymoderate
Complexity3/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

how do i run it?

Difficulty · moderate time til it works · 30min

Requires enabling experimentalDecorators and emitDecoratorMetadata in tsconfig.json plus a Reflect polyfill, neither is on by default in TypeScript.

MIT license, use freely for any purpose including commercial apps, with no restrictions beyond keeping the copyright notice.

in plain english

TSyringe is a lightweight library from Microsoft that handles dependency injection for TypeScript and JavaScript applications. Dependency injection is a pattern where a class declares what other objects it needs, and a central system (called a container) creates and supplies those objects automatically rather than having the class create them itself. This makes it easier to swap out components during testing or to change how the application is wired together without touching lots of files. The library works primarily through decorators, which are special annotations you attach to a class or its constructor parameters in TypeScript. For example, marking a class with the @injectable decorator tells TSyringe that it can be resolved by the container, meaning the container will create an instance of it and fill in its dependencies. A @singleton decorator does the same thing but ensures only one instance ever exists and is reused each time something asks for it. The container itself is a registry. You can register a class, a factory function, or a plain value under a named token, and then anywhere in your application you resolve that token to get back the object you registered. Child containers are supported for cases where you want a separate scope, and scoped lifetimes are available for finer control over how long instances live. Installing the library requires npm or yarn, and your TypeScript configuration must enable experimental decorators and decorator metadata, which are not on by default. A polyfill for the Reflect API is also required. The README includes working code examples for common scenarios including injection with and without interfaces, singleton registration, and injecting plain values by name. The project is hosted by Microsoft and released under the MIT license.

prompts (copy fr)

prompt 1
Show me how to set up TSyringe in a TypeScript project including the tsconfig changes needed for decorators, then write a simple service with constructor injection
prompt 2
How do I register a singleton database connection in TSyringe and inject it into multiple services without creating duplicate instances?
prompt 3
Write a unit test using TSyringe where I register a mock HTTP client in the container and inject it into a service under test
prompt 4
How do I use TSyringe child containers to scope dependencies per HTTP request in an Express.js app?
prompt 5
What is the difference between @singleton and @injectable in TSyringe, and when should I use each decorator?

Frequently asked questions

what is tsyringe fr?

TSyringe is a lightweight dependency injection library from Microsoft for TypeScript that uses decorators to automatically wire together class dependencies through a central container at runtime.

What language is tsyringe written in?

Mainly TypeScript. The stack also includes TypeScript, JavaScript, Node.js.

What license does tsyringe use?

MIT license, use freely for any purpose including commercial apps, with no restrictions beyond keeping the copyright notice.

How hard is tsyringe to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is tsyringe for?

Mainly developer.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.