Skip to content

Commit

Permalink
bugfix(core) use direct class instance
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 29, 2018
1 parent 385071b commit 5a6f64a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions packages/core/injector/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ export class Injector {
module: Module,
) {
if (isUndefined(param)) {
throw new UndefinedDependencyException(wrapper.name, dependencyContext, module);
throw new UndefinedDependencyException(
wrapper.name,
dependencyContext,
module,
);
}
const token = this.resolveParamToken(wrapper, param);
return this.resolveComponentInstance<T>(
Expand Down Expand Up @@ -293,7 +297,11 @@ export class Injector {
dependencyContext.name,
);
if (isNil(instanceWrapper)) {
throw new UnknownDependenciesException(wrapper.name, dependencyContext, module);
throw new UnknownDependenciesException(
wrapper.name,
dependencyContext,
module,
);
}
return instanceWrapper;
}
Expand Down Expand Up @@ -401,10 +409,9 @@ export class Injector {
): Promise<T> {
const { metatype, inject } = wrapper;
if (isNil(inject)) {
targetMetatype.instance = Object.assign(
targetMetatype.instance,
new metatype(...instances),
);
targetMetatype.instance = wrapper.forwardRef
? Object.assign(targetMetatype.instance, new metatype(...instances))
: new metatype(...instances);
} else {
const factoryResult = ((targetMetatype.metatype as any) as Function)(
...instances,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/injector/injector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('Injector', () => {
) as InstanceWrapper<MainTest>;

expect(instance.depOne).instanceof(DependencyOne);
expect(instance.depTwo).instanceof(DependencyOne);
expect(instance.depTwo).instanceof(DependencyTwo);
expect(instance).instanceof(MainTest);
});

Expand Down

0 comments on commit 5a6f64a

Please sign in to comment.