0

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?

2
  • Would you mind posting a complete example we can copy and paste. Commented Sep 15, 2016 at 12:38
  • 1
    You need to post more code of yours, for example what's ComponentRegistry? Commented Sep 16, 2016 at 0:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.