Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Better way to override @Model and @Routable constructor? #77

Closed
etsuo opened this issue Jun 4, 2017 · 1 comment
Closed

Better way to override @Model and @Routable constructor? #77

etsuo opened this issue Jun 4, 2017 · 1 comment

Comments

@etsuo
Copy link
Member

etsuo commented Jun 4, 2017

See "Class Decorators" here: https://www.typescriptlang.org/docs/handbook/decorators.html

function classDecorator<T extends {new(...args:any[]):{}}>(constructor:T) {
    return class extends constructor {
        newProperty = "new property";
        hello = "override";
    }
}

@classDecorator
class Greeter {
    property = "property";
    hello: string;
    constructor(m: string) {
        this.hello = m;
    }
}

console.log(new Greeter("world"));

Could this be used to get typing for injected methods without having to extend SakuraApiModel?

@etsuo
Copy link
Member Author

etsuo commented Jan 27, 2018

Switched to using mixins pattern with #111

@etsuo etsuo closed this as completed Jan 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant