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

Sealed classes #59

Open
chemerisuk opened this issue Oct 16, 2014 · 0 comments
Open

Sealed classes #59

chemerisuk opened this issue Oct 16, 2014 · 0 comments

Comments

@chemerisuk
Copy link

Hi @termi.

Tried to use ES6 syntax for classes and found that the output is not desired in some cases. As far as I understood by default it expects that a class can be inherited therefore adds some extra stuff. But in the real world not all classes need this addition, so I think it will be valuable to have something like below:

class Entry {
    constructor(b) {
        this.b = b;
    }

    toString() {
        return "foo";
    }

    toLocaleString() {
        return "bar";
    }
}

yields

function Entry(b) {
    this.b = b;
};

Entry.prototype = {
    toString: function() {
        return "foo";
    },

    toLocaleString: function() {
        return "bar";
    }
};

Such behavior might be declared using (for example):

/* es6-transpiler class-inheritance:false */

Thoughts?

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

1 participant