I am getting somewhere with this problem following this excellent post about manifesting objects by name, using the decorator approach. The code compiles, but I receive run-time errors.
I cannot get the playground on the page linked to above to execute: it just leads to a about:blank.
Here is my decorator code:
export function RegisterComponent(obj: ComponentType<GalleriaComponentBase>) {
new ComponentRegistry().RegisterComponent(obj);
}
I have tried applying my @RegisterComponent
decorator to the base class of the components, obj.name
is then equal to ComponentBase
which is, of course, no good.
So, I tried applying the decorator to each derived class, but I receive the following run-time error:
Argument of type 'typeof RepositoryComponent' is not assignable to parameter of type 'new () => ComponentBase'.
ComponentBase
looks like this:
export class GalleriaComponentBase {
refreshComponent() {};
getCustomUserComponentTypeFriendlyName() {};
}
Can anyone help?
ComponentRegistry
?