class IOC { private readonly items = new Map(); public set(key: Symbol, obj: T): void { this.items.set(key, obj); } public get(key: Symbol): T { return this.items.get(key) as T; } public create( key: Symbol, ...args: A ): T { const cls = this.get(key) as { new(...args: A): T; }; return new cls(...args); } } export const ioc = new IOC();