Interface as Tokens
Native support for useInterface
Zero-overhead dependency injection that shifts resolution from Runtime to Build-Time. No reflection, no decorators, just pure TypeScript.

Traditional DI containers like InversifyJS and tsyringe rely on runtime resolution:
NeoSyringe is different. It works as a compiler plugin:
// Pure TypeScript - no decorators!
interface ILogger {
log(msg: string): void;
}
class ConsoleLogger implements ILogger {
log(msg: string) { console.log(msg); }
}
class UserService {
constructor(private logger: ILogger) {}
}
// Configure the container
import { defineBuilderConfig, useInterface } from '@djodjonx/neosyringe';
export const container = defineBuilderConfig({
name: 'AppContainer',
injections: [
{ token: useInterface<ILogger>(), provider: ConsoleLogger },
{ token: UserService }
]
});
// Use it with full type safety
const userService = container.resolve(UserService);
// Type: UserService ✅ - Full auto-completion!The build plugin transforms your configuration into optimized code:
// Generated at build time
function create_ILogger() {
return new ConsoleLogger();
}
function create_UserService(container) {
return new UserService(container.resolve("ILogger"));
}
class NeoContainer {
resolve<T>(token: any): T { // ✨ Fully typed!
if (token === "ILogger") return this.getInstance("ILogger", create_ILogger);
if (token === UserService) return this.getInstance(UserService, create_UserService);
throw new Error(`Service not found: ${token}`);
}
}
export const container = new NeoContainer();Zero DI library shipped to production!