Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 5bdc90c

Browse files
Fix resolving of child when parent is registered
When you have class A in file A and class B in file B, that extends class A and you register both classes in the injector, trying to resolve the child (B) is leading to unexpected behavior. The constructor of B is called with arguments that are applicable to the base class (A). The reason is that the "extend" method is copying all properties from base class to the child. This includes the $inject property of the base class, so the annotate of the child class is not executed. Fix this by checking both $inject property and the name of the function.
1 parent bee77ac commit 5bdc90c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

yok.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function annotate(fn: any) {
3636
argDecl: string[];
3737

3838
if(typeof fn === "function") {
39-
if(!($inject = fn.$inject)) {
39+
if(!($inject = fn.$inject) || $inject.name !== fn.name) {
4040
$inject = { args: [], name: "" };
4141
fnText = fn.toString().replace(STRIP_COMMENTS, '');
4242
argDecl = fnText.match(FN_NAME_AND_ARGS);

0 commit comments

Comments
 (0)