Answer the question
In order to leave comments, you need to log in
How to rewrite this piece of code in typescript?
there is code in es6 . How to rewrite it into working code on ts. The example as in the documentation does not fit.
let Mixin1 = (superclass) => class extends superclass {
foo() {
console.log('foo from Mixin1');
if (super.foo) super.foo();
}
};
let Mixin2 = (superclass) => class extends superclass {
foo() {
console.log('foo from Mixin2');
if (super.foo) super.foo();
}
};
class S {
foo() {
console.log('foo from S');
}
}
class C extends Mixin1(Mixin2(S)) {
foo() {
console.log('foo from C');
super.foo();
}
}
new C().foo();
Answer the question
In order to leave comments, you need to log in
По хорошему, это делается на компонентах, как в Unity3D. Реализовать в TS (да и в ES2015+) можно на декораторах.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question