javascript - 如何在 Typescript 中扩展这两个类

标签 javascript typescript typescript2.0 typescript1.5

我需要从同一个命名空间扩展这两个类。

例如:

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
     }
}

我需要扩展“myNameSpace.class1”类以及“class2”命名空间。

class newClass extends myNameSpace.class1, myNameSpace.class2 {

   constructor() {
    super();
   }
}

如果我同时调用这两个类,我会收到一条错误消息

类只能扩展一个类

有没有其他方法可以解决 typescript 中的这个问题。

最佳答案

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

TypeScript 在设计上是单继承的。

关于javascript - 如何在 Typescript 中扩展这两个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48055702/

相关文章:

javascript - jQTouch 后退按钮

javascript - 使用 Next js 时在 CSS/SASS 模块中使用 kebab-case CSS 类名

javascript - 无法弄清楚如何访问 js 文件

reactjs - typescript 错误: Cannot find module 'moment'

typescript-typings - 如何修复节点类型的 tsc 抛出错误?

javascript - 对 TypeScript 类型的 ChildProcess 类的引用

javascript - 具有8个弧度的circle svg顺时针和逆时针旋转

angular - 'mat-toolbar' 不是已知元素 :

node.js - firebase 函数中的 "firebase serve"未运行最新更改

angular - 如何检查在 mat-select angular 8 单元测试中选择了哪个选项