fix: Using container.get/set methods with abstract class id
See original GitHub issueDescription
Here is the error message
TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'typeof IgpapiHttp' is not assignable to parameter of type 'ServiceIdentifier<unknown>'.
Type 'typeof IgpapiHttp' is not assignable to type 'Constructable<unknown>'.
Cannot assign an abstract constructor type to a non-abstract constructor type.
src/igpapi.ts (56:24)
56 this.container.set(IgpapiHttp, http);
~~~~~~~~~~
../../node_modules/typedi/types/container-instance.class.d.ts:50:5
50 set<T = unknown>(token: ServiceIdentifier, instance: T): this;
~~~
The last overload is declared here.
Here is the same error screenshot (maybe it’s more comfortable to read the colored text for someone)
Minimal code-snippet showcasing the problem
abstract class Foo {}
const container = new ContainerInstance('');
container.set(Foo, 1)
It doesn’t work for TypeScript "strict": true mode,
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Abstract Class getter and setter usage
You need to create abstract getter and setter only if you need change behaviour of getiin and setting for your variables.
Read more >Dependency injection in ASP.NET Core
Dependency injection addresses these problems through: The use of an interface or base class to abstract the dependency implementation.
Read more >In Java, should I write setters and getters in abstract class ...
No, I wouldn't. Try this. Replace the setters with a constructor. Set the private data you need with this constructor. Replace the getters...
Read more >Interfaces, Mixins and Building Powerful Custom Data ...
In Python, an interface is basically a specialized abstract class that defines one or more abstract methods. Abstract classes differs from ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thank you! When are you planning the next release?
Hi! I am focusing on class-validator currently, but I will try to pick up the reins here as well and see what will be released and make it happen.