Initially, let's take a look at the central Interface :
// IMySuperInterface.interface.ts
export interface IMySuperInterface<T = any> {
handle(arg?: any): Promise<T>;
}
Essentially, what I require is a shared type for ==> child classes with a 'handle' function. Something along the lines of :
function MyDummyFunction (param: {{class that extends IMySuperInterface)}})
I am attempting to enlist all classes in my application that implement my 'IMySyperInterface'
// MySuperImplementation.service.ts
@Feature('ReferenceA')
export class MySuperImplementation
implements IMySuperInterface {
constructor(private readonly logger: myLoggerService) {
this.logger.setContext(this);
}
async handle(someDummy: any): Promise<void> {
....
}
}
And here is the definition of the Decorator
// feature.decorator.ts
const _mapping = new Map<string, anyOrIdontKnowWhatToDo>();
export function Feature(key: string) {
return function (target: **HERE WHAT CAN I WRITE ??????**) {
Feature.cache.set(key, target);
return target;
};
}
I am trying to find some kind of 'AtLeastContains<IMySuperInterface>' or Type<IMySuperInterface>
with
export interface Type<T = any> extends Function {
new (...args: any[]): T;
}
However, I encounter:
- neither : sorry but 'prototype' is missing in IMySuperInterface
- neither : sorry but logger is not compatible with 'Type' type
I am confused :(.. How can I declare as a parameter of my function a Class that implements my Interface? Note: The argument in the constructor of my class changes constantly and so does the argument of the function in the interface.