3

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

Nealesh
  • 629
  • 6
  • 12
  • Which version are you using? There was a change made just before the release of 7.2.2 which may have fixed this, or caused it. https://github.com/openlayers/openlayers/pull/14395 – Mike Jan 21 '23 at 11:09
  • The version is 7.2.2 itself Mike. – Nealesh Jan 21 '23 at 11:49
  • Do you get the error if you revert to 7.1.0 ? If no error there then 7.2 has introduced it – Mike Jan 21 '23 at 12:21
  • With 7.1.0 the error is not coming. – Nealesh Jan 21 '23 at 17:51
  • The issue has been reported on github [here](https://github.com/openlayers/openlayers/issues/14477) and my friend has created a repo to recreate the issue [here](https://github.com/Hatooz/ol7.2.2Angular). You can also set `skipLibCheck` to `false` as a workaround. – Peter Feb 13 '23 at 10:09

2 Answers2

0

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

Peter
  • 37,042
  • 39
  • 142
  • 198
0

Got same error. I accidentally imported map like this

import Map from 'ol';

instead like this

import Map from 'ol/Map';
GDBxNS
  • 139
  • 6