Yes, we talked about this approach at TC39 at some point and it pretty much put mix-in discussions on the shelf. Basically ES6+ already supports mix-ins. This is the only mix-im pattern I ever use or show.
-
-
Those require a superclass, though, no? And/or some weirdness around having to call a phantom super constructor method.
1 reply 0 retweets 0 likes -
function MyMixIn(Super=Object) { … }
1 reply 0 retweets 0 likes -
That inherits unwanted stuff from Object though. It'd be nice if we could change the semantics of extending null so that it made a base class, and if base classes could call super() without an error.
2 replies 0 retweets 1 like -
Replying to @justinfagnani @awbjs and
Since I don't think you can't extend null in practice (no valid super ctor to call), maybe that's still possible.
2 replies 0 retweets 0 likes -
class extends null {} works. the super constructor is Function.prototype
2 replies 0 retweets 1 like -
You can make the declaration, but new throws: class C extends null {} new C(); > Uncaught TypeError: Super constructor null of C is not a constructor
1 reply 0 retweets 0 likes -
It not suppose to, see steps 5.b and 6.e.ii of https://tc39.github.io/ecma262/#sec-runtime-semantics-classdefinitionevaluation … But it looks like a spec. bug in step 10.ais cause the wrong default constructor go be generated. cc/
@bterlson@littledan1 reply 0 retweets 2 likes -
Might be fortuitous. Right now there's no way to write a class expression such that it could be either a base class or subclass depending on the result of the extends expression.
2 replies 0 retweets 0 likes -
Replying to @justinfagnani @tobie and
Seems like far less common use case then class extends null without and explicit constructor. Especially with the introduction of class fields.
1 reply 0 retweets 0 likes
Yeah. If that spec bug got implemented it should be fixed asap.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.