Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not use Property Decorator in mixin (Decorators are not valid here) #80

Open
jogibear9988 opened this issue Mar 27, 2019 · 1 comment

Comments

@jogibear9988
Copy link

I've a mixin like this

type Constructor<T> = { new (...args: any[]): T };

function VisuElement<B extends Constructor<any>>(base: B) {
    return class extends base {
     constructor(...args: any[]) {
         super();
         this._ve = true;
         this._veBindings = [];
     }

    static get properties() {
        return {
            unbindOnUnload: Boolean //Needed when a Element is created via a Dom repeat
        }

here it is not possible to replace static get properties() with decorator. => "Decorators are not valid here"

@tpluscode
Copy link

This is not an issue with the project but a limitation of TypeScript.

You need to name the class and return that instead:

function VisuElement<B extends Constructor<any>>(base: B) {
    class Mixin extends base { }

    return Mixin
}

Check here for inspiration: https://github.com/hypermedia-app/alcaeus-loader/blob/master/index.ts#L28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants