i'm trying to use open layers v7.2.2 with typescript. {without typescript the code works as expected}
function OnMapClick(Event : MapBrowserEvent<UIEvent>)
{
Event.map.forEachFeatureAtPixel(Event.pixel, function(CurrentFeature : Feature)
{
...
}
}
error : Type error: Argument of type '(CurrentFeature: Feature) => void' is not assignable to parameter of type '(arg0: FeatureLike, arg1: Layer<Source, LayerRenderer>, arg2: SimpleGeometry) => void'. Types of parameters 'CurrentFeature' and 'arg0' are incompatible. Type 'FeatureLike' is not assignable to type 'Feature'. Type 'RenderFeature' is missing the following properties from type 'Feature': on, once, un, geometryName_, and 40 more.
any help would be much appreciated. :-)
you don't need to declare the type of inline function use this:
function OnMapClick(Event : MapBrowserEvent<UIEvent>)
{
Event.map.forEachFeatureAtPixel(Event.pixel, function(CurrentFeature)
{
...
}
}