在TypeScript

时间:2015-08-06 17:24:52

标签: module typescript

我有一个TS模块,它包含一个内部模块,例如:

module abc.customer.ratings {

  module abc.customer.ratings.bo {
    export interface RatingScale {
      id: number;
      name: string;
      type: string;
    }
  }

  var scale: ??? // how to name the inner interface here?
}

我试过用:

  • RatingScale,只是名称 - 失败
  • bo.RatingScale - 内部模块名称(如相对路径)+只是名称 - 失败
  • abc.customer.ratings.bo.RatingScale - 来自世界之初的完整模块路径 - 工作

我的问题是 - 我可以用任何更短的方式使用它,因为有效的方法真的很冗长。

1 个答案:

答案 0 :(得分:2)

在此代码中:

module abc.customer.ratings {

  module abc.customer.ratings.bo {
    export interface RatingScale {
      id: number;
      name: string;
      type: string;
    }
  }

  var scale: ??? // how to name the inner interface here?
}

RatingScale的完全限定名称为abc.customer.ratings.abc.customer.ratings.bo.RatingScale。你可能想写的是:

module abc.customer.ratings {

  module bo {
    export interface RatingScale {
      id: number;
      name: string;
      type: string;
    }
  }

  var scale: bo.RatingScale;
}
相关问题