typed-trait
typed-trait copied to clipboard
What is super?
First of all, amazing work! This solves a real problem.
Consider this:
class A {
constructor(private foo = () => 'A') {
}
}
class B {
constructor(private foo = () => 'B') {}
}
class C extends mixin(A, B) {}
TypeScript is already complaining:
Property 'foo' has conflicting declarations and is inaccessible in type 'C'.
I'm confused what would be super when you extending mixins
Thanks @mohsen1! To get constructors to work, mixin() would have to synthesize a linear prototype chain. I feel sort of meh about doing that, because it means (1) constructing mixed in classes may produce side effects because constructor code will run, and (2) order of mixins now matters because it specifies the order in which constructors are run. That said, these are things that people probably expect from mixins, and if this lib doesn’t do those things, I should probably rename it “magical-traits” :).