我正在进行一个涉及TypeScript和Leaflet的项目。
扩展leaflet标记的文档(JS)方式如下:
L.Marker.Foo = L.Marker.extend({...});
然而,TypeScript 抱怨:
Property 'Foo' does not exist on type 'typeof Marker'.
如何更改以消除编译错误?
我正在进行一个涉及TypeScript和Leaflet的项目。
扩展leaflet标记的文档(JS)方式如下:
L.Marker.Foo = L.Marker.extend({...});
Property 'Foo' does not exist on type 'typeof Marker'.
如何更改以消除编译错误?
扩展Marker如下:
export class TSMarker extends L.Marker {
options: L.MarkerOptions
constructor(latLng: LatLngExpression, options?: L.MarkerOptions) {
super(latLng, options)
}
greet(): this {
this.bindPopup("Hello! TSX here!")
return this
}
}