在 TypeScript 中访问嵌套模块的 interface/class
Accessing interface/class of a nested module in 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
- 内部模块名称(如相对路径)+ 名称 - failed
abc.customer.ratings.bo.RatingScale
- 从世界开始的完整模块路径 - 有效
我的问题是 - 我能以任何更短的方式使用它吗,因为行之有效的方式非常冗长。
在此代码中:
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;
}
我有一个包含内部模块的 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
- 内部模块名称(如相对路径)+ 名称 - failedabc.customer.ratings.bo.RatingScale
- 从世界开始的完整模块路径 - 有效
我的问题是 - 我能以任何更短的方式使用它吗,因为行之有效的方式非常冗长。
在此代码中:
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;
}