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

[Option] Should it separate assignment types (constructor, traits, properties, methods) #17

Open
AMorgaut opened this issue Mar 5, 2017 · 0 comments

Comments

@AMorgaut
Copy link
Owner

AMorgaut commented Mar 5, 2017

This plugin currently mixes the prototype methods and constructor property (when extending another class) assignments

Object.assign(MyClass.prototype, {
    myMethod: function myMethod(a, b, c) {
        // do things
    }, 
    constructor: MyClass
});

Should there be an option (let's call it "explicit") for a more readable format such as

Object.assign(MyClass.prototype, {
        constructor: MyClass
}, { 
    myMethod: function myMethod(a, b, c) {
        // do things
    }, 
});

Note that It doesn't have much sense at runtime and reduce a little the performance, but it can be interesting in dev mode, even more if we add support to class properties or even to unofficial traits

ex:

Object.assign(MyClass.prototype, 
  {
        constructor: MyClass
  }, 
  Trait1, 
  Trait2, 
  { 
    myMethod: function myMethod(a, b, c) {
        // do things
    }, 
  }
);
Object.assign(MyClass, {
        staticProperty: 42,
        staticProperty2: 51,
}, { 
    staticMethod: function staticMethod(a, b, c) {
        // do things
    }, 
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant