I found a solution suggestion in this link and tried to implement it to my project by adding below code in a global (ts) file.
interface Component { }
type ComponentClass = { new (): Component };
const REGISTRY = new Map<string, ComponentClass>();
function getTypeFor(name: string): ComponentClass {
return REGISTRY.get(name);
}
function register(cls: ComponentClass): void {
REGISTRY.set(cls.name, cls);
}
and then registered my every component like below:
class ComponentA implements Component { ... }
register(ComponentA);
I am getting my component type with getTypeFor method. Everything was nearly perfect when i try to put a parameter in constructor of a component. As i see, this "ComponentClass" type waiting a no parameter constructor. How can i use this method or any other solution if my cnonstructor have parameter(s).