TypeScript Mixins -


typescript 2.2 added mixins. however, when try run sample code, shows error, saying base not constructor function type.

class point {     constructor(public x: number, public y: number) {} }  class person {     constructor(public name: string) {} }  type constructor<t> = new(...args: any[]) => t;  function tagged<t extends constructor<{}>>(base: t) {     return class extends base { //error here         _tag: string;         constructor(...args: any[]) {             super(...args);             this._tag = "";         }     } }  const taggedpoint = tagged(point);  let point = new taggedpoint(10, 20); point._tag = "hello";  class customer extends tagged(person) {     accountbalance: number; }  let customer = new customer("joe"); customer._tag = "test"; customer.accountbalance = 0; 

is there needs changed in declaration of constructor remove error?

(related, if ts team reads this, handbook on mixins appears out of date.)


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -