Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend the two classes in Typescript [duplicate]

I need to extend the two classes from the same namespace.

for ex:

declare namespace myNameSpace{

   class class1{
       ///some methods will be here
    }
    class class3 extends class1{
      //some method wil be here
    }
    class class2 extends myNameSpace. class3 {
       //some methods will be here
    }
    export namespace  class2 {
       //declaration will be here
     }
}

i need to extend the 'myNameSpace.class1' class as well as 'class2' namespace.

class newClass extends myNameSpace.class1, myNameSpace.class2 {

   constructor() {
    super();
   }
}

If i call the both the classes, i got an error message

classes can only extend a single class

Is there any other way to fix this issue in typescript.

like image 682
Kalai Avatar asked Dec 13 '25 09:12

Kalai


1 Answers

Is there any other way to fix this issue in typescript.

TypeScript is single inheritance by design.

like image 129
basarat Avatar answered Dec 14 '25 22:12

basarat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!