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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -