Comparing version 0.4.0 to 0.4.1
@@ -44,2 +44,3 @@ "use strict"; | ||
var registeredService = this.findRegisteredService(name, type); | ||
// console.log("registeredService: ", registeredService); | ||
if (registeredService) { | ||
@@ -65,4 +66,4 @@ if (!type) | ||
var objectInstance = new (type.bind.apply(type, params))(); | ||
this.instances.push({ name: name, type: type, instance: objectInstance }); | ||
this.applyPropertyHandlers(type); | ||
this.instances.push({ name: name, type: type, instance: objectInstance }); | ||
return objectInstance; | ||
@@ -105,3 +106,3 @@ }; | ||
this.propertyHandlers | ||
.filter(function (propertyHandler) { return propertyHandler.target.constructor === target; }) | ||
.filter(function (propertyHandler) { return propertyHandler.target.constructor === target || target.prototype instanceof propertyHandler.target.constructor; }) | ||
.forEach(function (propertyHandler) { | ||
@@ -144,3 +145,5 @@ Object.defineProperty(propertyHandler.target, propertyHandler.key, { | ||
return this.registeredServices.filter(function (service) { return !service.name; }).reduce(function (found, service) { | ||
return service.type === type ? service : found; | ||
// console.log(service.type, "::", type); | ||
// console.log(type.prototype instanceof service.type); | ||
return service.type === type || type.prototype instanceof service.type ? service : found; | ||
}, undefined); | ||
@@ -147,0 +150,0 @@ }; |
@@ -11,3 +11,3 @@ /** | ||
*/ | ||
export declare function Inject(type?: Function): Function; | ||
export declare function Inject(type?: (type?: any) => Function): Function; | ||
export declare function Inject(serviceName?: string): Function; | ||
@@ -14,0 +14,0 @@ /** |
@@ -19,3 +19,3 @@ "use strict"; | ||
if (!typeOrName) | ||
typeOrName = Reflect.getMetadata("design:type", target, key); | ||
typeOrName = function () { return Reflect.getMetadata("design:type", target, key); }; | ||
if (index !== undefined) { | ||
@@ -25,3 +25,3 @@ Container_1.Container.registerParamHandler({ | ||
index: index, | ||
getValue: function () { return Container_1.Container.get(typeOrName); } | ||
getValue: function () { return Container_1.Container.get(typeof typeOrName === "string" ? typeOrName : typeOrName()); } | ||
}); | ||
@@ -33,3 +33,3 @@ } | ||
key: key, | ||
getValue: function () { return Container_1.Container.get(typeOrName); } | ||
getValue: function () { return Container_1.Container.get(typeof typeOrName === "string" ? typeOrName : typeOrName()); } | ||
}); | ||
@@ -36,0 +36,0 @@ } |
{ | ||
"name": "typedi", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Dependency injection for Typescript", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28267
363