I've been trying to figure out inheritance / mixin approach for the past few days.
And I've seen a few methods around
polytype seems to be the most robust approach I have come acorss based on the documentation so far.
I was wondering if there was some nice comparison of some of the common approaches and pitfalls or other approaches that could exist ?
For example -
- The single inheritance available in JS now prototype replacement (which does not allow multiple inheritance)
- The approach of modifying the prototype of classes - like
Object.assign(MyClass.prototype, MyMixin); (which does not allow me to use super(), instanceof, doesnt handle typing, etc.)
- The approach mentioned in typescript's mixin documentation right now about dynamic classes inherited in a function (Which has a bit of an awkward syntax ? But seems to handle everything else ?)
- ts-mixer
And so on.
I've been trying to figure out inheritance / mixin approach for the past few days.
And I've seen a few methods around
polytype seems to be the most robust approach I have come acorss based on the documentation so far.
I was wondering if there was some nice comparison of some of the common approaches and pitfalls or other approaches that could exist ?
For example -
Object.assign(MyClass.prototype, MyMixin);(which does not allow me to use super(), instanceof, doesnt handle typing, etc.)And so on.