OpenLayers 错误 TS2416:类型 'Geolocation' 中的属性'on'不能分配给基本类型 'BaseObject' 中的相同属性



我试图在我的Angular项目中显示地图与OpenLayers库。在我的代码中添加了Map对象后,应用程序开始出现以下错误。

node_modules/ol/Geolocation.d.ts:103:5 - error TS2416: Property 'on' in type 'Geolocation' is not assignable to the same property in base type 'BaseObject'.
Type 'GeolocationOnSignature<EventsKey>' is not assignable to type 'ObjectOnSignature<EventsKey>'.
Type 'GeolocationOnSignature<EventsKey>' is not assignable to type 'OnSignature<EventTypes, BaseEvent, EventsKey>'.
Types of parameters 'type' and 'type' are incompatible.
Type 'EventTypes' is not assignable to type '"change"'.
Type '"error"' is not assignable to type '"change"'.
103     on: GeolocationOnSignature<import("./events").EventsKey>;
~~
[webpack-dev-server] ERROR
node_modules/ol/Geolocation.d.ts:107:5 - error TS2416: Property 'once' in type 'Geolocation' is not assignable to the same property in base type 'BaseObject'.
Type 'GeolocationOnSignature<EventsKey>' is not assignable to type 'ObjectOnSignature<EventsKey>'.
107     once: GeolocationOnSignature<import("./events").EventsKey>;
~~~~
[webpack-dev-server] ERROR
node_modules/ol/Geolocation.d.ts:111:5 - error TS2416: Property 'un' in type 'Geolocation' is not assignable to the same property in base type 'BaseObject'.
Type 'GeolocationOnSignature<void>' is not assignable to type 'ObjectOnSignature<void>'.
Type 'GeolocationOnSignature<void>' is not assignable to type 'OnSignature<EventTypes, BaseEvent, void>'.
Types of parameters 'type' and 'type' are incompatible.
Type 'EventTypes' is not assignable to type '"change"'.
Type '"error"' is not assignable to type '"change"'.
111     un: GeolocationOnSignature<void>;

有谁能帮忙解决这个问题吗?

问候,Nealesh

如果pull请求被合并,这应该在OL的下一个版本中修复。

得到相同的错误。我不小心像这样导入了map

import Map from 'ol';

而不是像这样

import Map from 'ol/Map';