microsoft / microsoft/tsyringe
Class properties are lost when decorating on Node 13.X
Open
@Xapphire13 is already working on this.
Since Jan 30, 2020.
awaiting triage
- Dominant language
- TypeScript
- Stars
- 6k
- Forks
- 184
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
Describe the bug
When using Node 13, accessing the constructor property of the class is hidden by the decorators of tsyringe.
To Reproduce
import "reflect-metadata";
import { autoInjectable } from "tsyringe";
abstract class Service {
serviceName(): string {
return this.constructor.name;
}
}
function printClass<T extends Service>(): (target: any) => void {
return function(target: any): void {
console.log("Decorator for: ", target.name);
};
}
@printClass()
@autoInjectable()
class AutoInjectableClass extends Service {}
console.log("AutoInjectable instance name: ", new AutoInjectableClass().serviceName());
@printClass()
class RegularClass extends Service {}
console.log("Regular instance name: ", new RegularClass().serviceName());
Node 13.X:
Decorator for:
AutoInjectable instance name:
Decorator for: RegularClass
Regular instance name: RegularClass
Expected behavior
Node 12.X:
Decorator for: AutoInjectableClass
AutoInjectable instance name: AutoInjectableClass
Decorator for: RegularClass
Regular instance name: RegularClass
Version:
Node > 13.0
Tsyringe 3.7.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.