I am trying to show Map with OpenLayers library in my Angular project. The app started breaking with following error after I added Map object in my code.

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>;

Can anybody help fix this.

Regards, Nealesh

2

There are 2 answers

0
Peter On

This should be fixed in the next release of OL if the pull request is merged.

0
GDBxNS On

Got same error. I accidentally imported map like this

import Map from 'ol';

instead like this

import Map from 'ol/Map';