const injectables = new Map ( ) ; export const INJECTABLE_METADATA = "injectable_metadata" ; export type Constructor < T = any > = new ( ... args ) => T ; export const IocFactory = ( target ) : any => { const providers = Reflect . getMetadata ( "design:paramtypes" , target ) ; const args = providers ? providers . map ( ( provider ) => injectables . get ( provider ) || IocFactory ( provider ) ) : [ ] ; return new target ( ... args ) ; } ; export const Injectable = ( ) : ClassDecorator => ( target ) => { const Obj = ( target as unknown ) as Constructor < any > ; if ( ! injectables . get ( target ) ) { injectables . set ( target , IocFactory ( Obj ) ) ; } } ;