Skip to content

FEATURE: support for mixin/trait (by language new keyword) #16787

Closed
@kamil-kielczewski

Description

@kamil-kielczewski

TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx)

Code

In typescript documentation about mixins is described that typescript support mixins/traits - this is in fact not true because programmer need implements everything himself - so where is support?.

Proper support for mixin should be by language KEYWORD like mixin or trait & use (like in php). And programer should use it in this way (without double mixin methods definition stub):

class SmartObject mixin Disposable, Activatable {
    constructor() {
        setInterval(() => console.log(this.isActive + " : " + this.isDisposed), 500);
    }

    interact() {
        this.activate();
    }
}

(i use example context from documentation for which link I give above)

And thats all! Any rendundant mehtod/fields deinition shouldn't be inside class SmartObject and also any applyMixins should not be written by TS programmer. If we will achieve this, then we can say that TS support mixins/traits.

Expected behavior:

Look description above

Actual behavior:

Look description above

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdOut of ScopeThis idea sits outside of the TypeScript language design constraints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions