Hacker News new | past | comments | ask | show | jobs | submit login

Always getting 'app.js:22 Uncaught TypeError: Cannot set property 'kind' of undefined' :-(

However, I doubt that I would use it - most of the 'modernizations' are really dependent on the context of each change and require some tweaking.

For instance, ES6 classes do not allow for inline computed methods:

  const x = function () {};

  x.prototype.a = wrapFunction(function(){});
--- this is impossible: ---

  class x {
     a() wrapFunction(function(){}); // invalid :-(
  }
So we're still required to use the explicit prototype way of declaring the class.

Then you can't just rewrite all methods to arrow functions because they don't have prototypes, even when they're really tempting:

  var x = function () {};
  x.prototype.a = <foo>;
--->

  var x = () => {};
  x.prototype.a = <foo>; // cannot set a of undefined
...

$0.02




If you don't mind setting the function on instances at construct time, you can use ES2016 class properties:

    class x {
      a = wrapFunction(function() {})
    }
This kind of use case is pretty well covered by ES2016 decorators as well (they're a bit more general as they act on property descriptors, not just values):

    class x {
      @functionWrapper
      a() {}
    }


Neat, thanks! But we're working with the half-baked V8 ES6 support that is far from ES2016, unfortunately. However, it's interesting to see the support coming :-)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: