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

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

Closed
kamil-kielczewski opened this issue Jun 28, 2017 · 2 comments
Closed

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

kamil-kielczewski opened this issue Jun 28, 2017 · 2 comments
Labels
Duplicate An existing issue was already created Out of Scope This idea sits outside of the TypeScript language design constraints

Comments

@kamil-kielczewski
Copy link

kamil-kielczewski commented Jun 28, 2017

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

@ghost
Copy link

ghost commented Jun 28, 2017

Duplicate of #7798 and #2919.
See TypeScript's design goals. Specifically: Avoid adding expression-level syntax. (This would presumably affect class expressions.)

@ghost ghost added Duplicate An existing issue was already created Out of Scope This idea sits outside of the TypeScript language design constraints labels Jun 28, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 11, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 11, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created Out of Scope This idea sits outside of the TypeScript language design constraints
Projects
None yet
Development

No branches or pull requests

2 participants