Skip to content

Commit 9d2948c

Browse files
author
Umed Khudoiberdiev
committed
moved metadata read from decorator into container class
1 parent 5963d18 commit 9d2948c

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typedi",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "Dependency injection for TypeScript",
55
"license": "MIT",
66
"readmeFilename": "README.md",

src/Container.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ export class Container {
9090
}
9191

9292
// setup constructor parameters for a newly initialized service
93-
let params: any[] = service.paramTypes ? this.initializeParams(type, service.paramTypes) : [];
93+
const paramTypes = Reflect && (Reflect as any).getMetadata ? (Reflect as any).getMetadata("design:paramtypes", type) : undefined;
94+
let params: any[] = paramTypes ? this.initializeParams(type, paramTypes) : [];
9495

9596
// if factory is set then use it to create service instance
9697
if (service.factory) {

src/decorators/Service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export function Service<T, K extends keyof T>(optionsOrServiceName?: ServiceOpti
3030
return function(target: Function) {
3131

3232
const service: ServiceMetadata<T, K> = {
33-
type: target,
34-
paramTypes: (Reflect as any).getMetadata("design:paramtypes", target)
33+
type: target
3534
};
3635

3736
if (typeof optionsOrServiceName === "string" || optionsOrServiceName instanceof Token) {

src/types/ServiceMetadata.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ export interface ServiceMetadata<T, K extends keyof T> {
2525
*/
2626
factory?: [ObjectType<T>, K]|((...params: any[]) => any);
2727

28-
/**
29-
* Parameter types passed used to determine class dependencies of the service.
30-
*/
31-
paramTypes?: any[];
32-
3328
/**
3429
* Instance of the target class.
3530
*/

0 commit comments

Comments
 (0)