我试图从Typescript调用一个javascript类,但是编译器(VS)抛出了一个不稳定的异常。
这个类本身就是InfoBox,但不幸的是我找不到它的typescript定义。
当我试图在我的TS类中使用它时,它抱怨它找不到名称"InfoBox“。
public showInfoWindow(latLng: google.maps.LatLng, map: google.maps.Map): InfoBox {
var infobox = new InfoBox({
// ...
}
return infobox;
}在InfoBox.js文件中,使用prototype方法定义它,如下所示
function InfoBox(opt_opts) { ... }
InfoBox.prototype = new google.maps.OverlayView();发布于 2016-08-05 17:15:46
您可以自己声明类,例如,在文件InfoBox.d.ts中声明
// InfoBox.d.ts
declare class InfoBox {
constructor(obj: any);
// Here the members of InfoBox you use
}有关声明文件is here的文档。
https://stackoverflow.com/questions/38785253
复制相似问题