microsoft / microsoft/tsyringe
Custom constructor properties
Open
@Xapphire13 is already working on this.
Since Apr 29, 2020.
accepting PRs
enhancement
- Dominant language
- TypeScript
- Stars
- 6k
- Forks
- 184
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
Is there a way we can add a custom argument to a class constructor? e.g
@injectable()
class ExampleClass {}
@injectable()
class MyClass {
constructor(custom: CustomInterface, example: ExampleClass) {}
}
const instance = container.resolve(MyClass, { custom }); // not possible now but to illustrate my point
I need to provide a different custom object to the class on each instantiation. Basically this stackoverflow comment describes perfectly what I mean (quite surprised the library hasn't got this ability already tbh!)
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.