我想扩展此文件中 google.maps
命名空间中定义的类:
@types/googlemaps/index.d.ts
class MyMarker extends google.maps.Marker {
constructor(options: google.maps.MarkerOptions){
super(options);
}
}
这个转换没有错误。但在运行时,我在构造函数中收到错误,因为 google.maps
全局仍未定义。
我做错了什么?
最佳答案
您需要先导入它,例如
import Marker from 'googlemaps';
class MyMarker extends Marker
关于javascript - Typescript:如何使用命名空间中的类或接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40058243/