You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As an Javascript developer, I tried to implement the dependency injection, by using the tool introduced in rbuckton/ReflectDecorators (https://github.com/rbuckton/ReflectDecorators.git). However, I just found the following code will be compiled into an anonymous class declaration in js file.
I am so frustrated to see that constructor A is actually a class without name - the target in decorator code is an actually anonymous constructor function.
I do not know why. I can not figure out why make it anonymous if one decorator is there. As a result, I have to implement it like the following, which looks really odd and confusing, by using metadata Reflect API:
After investigation in sources of Typescript, I found the following lines related to this issue:
in function emitClassLikeDeclarationForES6AndHigher(node), it reads:
So while compiling class A, thisNodeIsDecorated is true and the name is never emitted. May I ask why? Would it better to just emit class name, like the following? Please let me know, if I missed something. Thanks very much.
As an Javascript developer, I tried to implement the dependency injection, by using the tool introduced in rbuckton/ReflectDecorators (https://github.com/rbuckton/ReflectDecorators.git). However, I just found the following code will be compiled into an anonymous class declaration in js file.
The decorator @log is quite simple, it is to print the class name.
The generated javascript is as follows. I turned "emitDecoratorMetadata" to true in tsconfig.json
I am so frustrated to see that constructor A is actually a class without name - the target in decorator code is an actually anonymous constructor function.
I do not know why. I can not figure out why make it anonymous if one decorator is there. As a result, I have to implement it like the following, which looks really odd and confusing, by using metadata Reflect API:
After investigation in sources of Typescript, I found the following lines related to this issue:
in function emitClassLikeDeclarationForES6AndHigher(node), it reads:
So while compiling class A, thisNodeIsDecorated is true and the name is never emitted. May I ask why? Would it better to just emit class name, like the following? Please let me know, if I missed something. Thanks very much.
The text was updated successfully, but these errors were encountered: