Skip to content

Next-generation dependency injection for TypeScript

InferDICatch wiring errors before you run

Compiler-checked dependency graphs. Fast resolution. A runtime under 3 KiB. Your business logic stays ordinary TypeScript

pnpm add @inferdi/inferdi
< 3 KiBgzip runtime
6.23 nscached resolve
0runtime dependencies

Fast by design

A cached resolve starts with one Map.get(). The default contract keeps runtime checks on cold resolution.

Methodology and full results

Medians from the recorded eight-round production benchmark. Container overhead, not application throughput. .

TypeScript sees the whole graph ​

Each registration returns a new container type that records its key, value, lifetime, async edge, and scope requirements.

ts
import { 
Container
} from '@inferdi/inferdi'
class
Logger
{
info
(
message
: string) {}
} class
Database
{
findUser
(
id
: string) {
return {
id
}
} } class
UserRepo
{
constructor(readonly
logger
:
Logger
, readonly
database
:
Database
) {}
} const
container
= new
Container
()
.
registerClass
('logger',
Logger
, [])
.
registerClass
('database',
Database
, [])
.
registerClass
('users',
UserRepo
, ['logger', 'database'])
const
users
=
container
.
get
('users')
const users: UserRepo

Framework adapters ​

Next step

Start at the composition root

Keep the graph in one place, where its choices are easy to read and change.