[英]TypeScript: how to call a custom utli JS function from TypeScript class
EXAMPLE: JS utilities function like so : 示例:JS实用程序的功能如下:
BDA.Utils.formatString = function (string) {
(....)
return someFormattedStr;
}
now I want to call this from my TS class, like so: 现在我想从我的TS类中调用它,就像这样:
export class Building {
image: string;
get getFormatted(): string {
return BDA.Utils.formatString (this.image);
}
}
I get a warning/error in type script saying that, basically, it does recognize BDA.Utils 我在类型脚本中收到警告/错误,说基本上,它确实可以识别BDA.Utils
is there anyway to make TS ignore this? 反正有让TS忽略这一点吗? or define this as interface or something to make it assume that such a thing exists?
或将其定义为接口或某种东西以使其假定存在这种东西? My main problems is nesting of the modules/classes BDA->Utils
我的主要问题是模块/类BDA-> Utils的嵌套
Add this to your code: 将此添加到您的代码:
declare module BDA.Utils {
function formatString(s: string): string;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.